https://www.cnblogs.com/rocky404/p/6734958.html
一、有主键去重
a、单字段重复
table ab
查询重复记录(一条)
1 |
|
result:
查询重复记录(全部)
1 |
|
result:
删除重复记录保留一条
1 2 3 4 5 |
|
刚开始想到这个sql,结果
于是经过查资料,sql整改
1 2 3 4 5 6 7 8 9 |
|
去重成功!
b、多字段重复
table ab
查询重复记录(一条)
1 |
|
result:
查询重复记录(全部)
1 |
|
result:
删除重复记录保留一条
1 2 3 4 5 6 7 8 9 |
|
去重成功!
二、无主键去重
单字段、多字段
table ab
删除重复记录保留一条
1 2 3 4 5 6 7 8 9 10 11 12 |
|
去重成功!