There are couple of ways you can do it.

1) You can use the following sql to find out duplicate rows and then 
write few more sql to delete duplicate.

SELECT column(s), count(*)
FROM
     table-a
GROUP BY column(s)
HAVING count(*) > 1;

then massage the data with couple of more sqls.

2) This way you can dump unique rows in another table and then drop 
this table, recreate it and copy the unique rows.

CREATE TABLE table-B (structure same as table-A);

INSERT INTO table-B SELECT DISTINCT * FROM table-A; ( Assumption is 
that rows are duplicated)

DROP TABLE table-A; 

RENAME TABLE table-B TO table-A;

3) You can try;

ALTER IGNORE TABLE table-A add unique (columns_with_unique_values);

Be careful in using this as there are some issues with this.



cheers

Vivek











> -----Original Message-----
> From: oswaldo [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 26, 2002 11:20 AM
> To: mysql
> Cc: oswaldo
> Subject: Duplicate Keys
> 
> 
> Hi List
> 
> Sorry for the newbie question.
> 
> Im new to MySQL. I have a table that I don't know how many 
> duplicate records
> it has, so how do I query and delete all the duplicate (or 
> many multiple)
> records from a MySQL table ?
> 
> Thanks in advance
> 
> Oswaldo Castro
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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

Reply via email to