一条删除部分字段重复的SQL命令
问题:有一个数据表,名为custom ,有两个字段(ID、title)
有一些记录的title字段重复。想把title字段重复的保留一条即可,其它全部删掉。
方法:delete from custom where id not in(select min(id) from custom group by title)
问题:有一个数据表,名为custom ,有两个字段(ID、title)
有一些记录的title字段重复。想把title字段重复的保留一条即可,其它全部删掉。
方法:delete from custom where id not in(select min(id) from custom group by title)