View Single Post
Old 02-18-2013, 01:29 AM   PM User | #1
mharrison
New Coder

 
Join Date: Dec 2012
Posts: 52
Thanks: 12
Thanked 0 Times in 0 Posts
mharrison is an unknown quantity at this point
Delete Duplicates

I'm running the following query to gather a list of duplicates based on 2 fields....lnktxt and cattxt:

SELECT P1.lnktxt, P1.cattxt, P1.dsptxt
FROM TABLE AS P1,
( SELECT lnktxt, cattxt, dsptxt, COUNT(*) AS howmany
FROM TABLE
GROUP BY lnktxt, cattxt, dsptxt
HAVING howmany > 1 ) AS P2
WHERE P1.lnktxt = P2.lnktxt AND P1.cattxt = P2.cattxt

It is displaying fine, and in PHPMyAdmin when I check the boxes to delete the individual records, it is not releasing the P1.lnktxt and the SQL server is erroring out. Is there a better method to gather and display a list of duplicates?
I don't want them to be automatically deleted, I would like to review the records first and select which one to delete.
mharrison is offline   Reply With Quote