[thelist] simple sql question

Matt Warden mwarden at gmail.com
Fri Nov 24 14:05:44 CST 2006


On 11/24/06, Brian Cummiskey <brian at hondaswap.com> wrote:
> SELECT max(fileid) FROM files
> GROUP BY title HAVING count(*) >1

I assume you want to delete the record with the maximum fileid for
each title. Something like this should get you started in the right
direction:

delete from files
where fileid in (
     select max(fileid)
     from files
     group by title
)

This assumes that fileid is the sole member of a candidate key.

-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list