Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete duplicate row from a table

Status
Not open for further replies.

satellite03

IS-IT--Management
Dec 26, 2003
248
IN
how to delete duplicate row from a table . the rows are differed only by the first column.

like this


1 abc def ghi

2 abc def ghi

3 abc def ghi

except the first column(i.e system generated serial number )records are same. i want to keep only one record (i.e first record only)

what would be sql query ?

if it was not a system generated serial number(rathera field value ) then how can i do the same ?
 
Assuming the column names are id, col1, col2 and col3:

DELETE FROM sometable
WHERE id NOT IN
(SELECT MIN(id)
FROM sometable
GROUP BY col1, col2, col3)


In this case I see no difference between system generated number or not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top