怎样删除数据库中重复的信息,只保留一条

时间:2022-10-21 22:19:05
庞大的数据库中存在着很多重复的信息,怎样把他们删除呢?
比如:有一个user的表
id name tel city time ....
1 aa 1234
2 cc 4653
3 aa 1234
4 bb 89752
5 aa 1234
6 asd 54656
7 aaa 1234
我想把name和tel字段中重复的信息删掉
得出的结果如下:
id name tel city time ....
1 aa 1234
2 cc 4653
4 bb 89752
6 asd 54656
7 aaa 1234

请问各位高手怎样实现啊!

delete from user where exists(select 1 from user a where a.name=user.name and a.tel=user.tel and a.id<user.id)