Syntax Question: deleting previous duplicate entries

2001-08-30 Thread Tom Churm

hi,

i've got a table collecting info from html forms.  problem is, certain
wiseguys always make multiple entries.  could someone clue me in to how
i can select the Last entry where there is a duplicate for the User
(type text, these are email addresses), and automatically delete any
previous entries?  i'm using a column 'id' int auto_increment as my
index: the last entry from a User will automatically have a higher id #.

example:  i've only gotten this far: this selects all users with
multiple entries

SELECT * from table_name GROUP BY User HAVING Count(User)  1

thanks muchly,

tom

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Updating auto_increment ID Column/Selecting Duplicate Rows

2001-08-28 Thread Tom Churm

hi,

i have 2 questions that i badly need answered.  i use phpmyadmin, but 
any answers containing SQL syntax should work in this app...

1)
this should be simple but i don't know it.  i use the following mysql
table field as the Key for my tables:

id int(10) unsigned NOT NULL auto_increment,

now, when i have to clean up items in my tables, like when users have
sent off a .html form multiple times and i want to delete duplicate
submissions, how can i quickly  easily update all of the 'id' fields in
the entire table, to reflect the numeration change?

now, using phpmyadmin, if i go in and delete a few entries, the id's
have gaps in them.

2)
in a table i have a column called User.  some people have entered things
into this table multiple times.  how do i create a SELECT statement to
select
only those rows that have multiple Users?  i need something like this
(but this
is wrong, of course):

SELECT * FROM mail_form2 WHERE 'count(User) 1' 

many thanks from a newbie,

tom

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php