table1(a,b) a b 1 10 2 20 3 30 4 10 5 10 删除有重复字段内容的记录,只保留一条。 delete from table1 where goodid not in (select max(goodid) from table1 group by goodin) 删除所有有重复字段内容的记录。 select * from table1 delete from table1 where goodin in (select goodin from table1 group by goodin having count(*)>1) 删除所有不重复字段内容的记录。 delete from table1 where goodin in (select goodin from table1 group by goodin having count(*) < 2)
上面表字段a,b 改为goodid,goodin
删除所有有重复字段内容的记录。 delete from table1 where goodin in (select goodin from table1 group by goodin having count(*)>1)
a b
1 10
2 20
3 30
4 10
5 10
删除有重复字段内容的记录,只保留一条。
delete from table1
where goodid not in (select max(goodid) from table1 group by goodin)
删除所有有重复字段内容的记录。
select * from table1
delete from table1 where goodin in (select goodin from table1
group by goodin
having count(*)>1)
删除所有不重复字段内容的记录。
delete from table1 where goodin in (select goodin from table1 group by goodin having count(*) < 2)
delete from table1 where goodin in (select goodin from table1
group by goodin
having count(*)>1)