deleting duplicate rows

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

deleting duplicate rows

Post by GeXus »

I have a table with a bunch of duplicate data that I want to delete there are too many to do one by one, is there anyway to do this outside of using temp tables?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

it depends on what dbms you're using (version and type).

you could sub query for duplicates using a HAVING clause and then delete with a limit of 1.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Self-joins can be used too.
Post Reply