sql - Delete rows with duplicate value in one column but different value in other columns -
i have table 3 columns :
id, name, role some names duplicated have unique id, how delete rows duplicated name(not all,leave 1 each) in table?
group name , select lowest unique id. delete records not in list
delete your_table id not in ( select min(id) your_table group name ) and if use mysql need subquery since mysql not allow delete same table selecting from:
delete your_table id not in ( select * ( select min(id) your_table group name ) tmp_tbl )
Comments
Post a Comment