View Single Post
Old 02-19-2013, 03:25 AM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
You *MUST* also SELECT the primary key field!

If you do that, in PHPMyAdmin, it should then be able to delete the records based on that primary key.

I don't use PHPMyAdmin, but I could certainly build a web page that would allow this in under an hour, for example.

Code:
SELECT P1.uniqueid, 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 AND P1.dsptxt = P2.dsptxt
ORDER BY lnktxt, cattxt, dsptxt
And if you are going to count two records as identical only if all THREE fields agree (lnktxt, cattxt, dsptxt -- which is the meaning of your GROUP BY and HAVING there), then you really should also include those in the WHERE clause, as shown.

If you don't care about whether dsptxt is duplicated or not, then don't use it in the subquery.

Also, if you don't specify an ORDER BY clause, there is no guarantee that identical (except for uniqueid) records will be even close together in the output.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote