删除(除主键外)的重复数据

[color=red]user表
id name age
1 a 10
2 b 20
3 c 30
4 b 20
5 c 30
6 a 10
7 a 10
删除(除主键外-自增)的重复数据
sql语句[/color]

2个回答

delete from user where id not in (select min(id) from user group by name, age)

delete from mytest where id not in ( select t1.id from mytest t1 group by t1.name,t1.age)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问