Hiya Linsen
First off all I'm not sure if you can SELECT and DELETE at the same time, so
you might want to make a script (PHP?) that SELECT's the appropriate rows
and deletes the ones with duplicates. Yes, I normally work with MySQL/PHP
combined! *smile* On the other hand you could make a query using COUNT and
GROUP BY that selects all rows grouped and then delete the rows with the
same ID - watch :
SELECT username, COUNT(username) AS found FROM profiles GROUP BY username
ORDER BY found;
This way you get rows with a username and the number of times the username
is used. (Kind of bad example, but you should get the idea) Then delete
records from the table where found is more than one.
/Jacob
-----Oprindelig meddelelse-----
Fra: Linsen Limsico [mailto:[EMAIL PROTECTED]]
Sendt: 8. februar 2001 18:13
Til: mysql_list
Emne: Finding Duplicates and Deleting
Does anyone know how to find duplicates in a table and deleting them. I
can't figure out how to structure the query.
Linsen
---------------------------------------------------------------------
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