Page 1 of 1

Delete duplicate enties

Posted: Wed May 17, 2006 2:48 am
by leewad
Hi

how can I delete duplicate entries from a mysql database? The query to display them I have is:

Code: Select all

SELECT 
DISTINCT url, COUNT( url ) AS qty 
FROM 
table 
GROUP BY 1 HAVING qty > 1
But how can I delete them?

Many thanks

Posted: Wed May 17, 2006 6:49 am
by dibyendrah
Dear leewad,

Have a look at this solution .
Create a new table with just distinct entries?

Code: Select all

CREATE new_tbl SELECT id, url
FROM old_tbl
GROUP BY url;
This will create a new table with just the distinct URLs.

Dibyendra