SQL可以查找具有重复记录的记录吗? [英] Is it possible for SQL to find records with duplicates?
本文介绍了SQL可以查找具有重复记录的记录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用SQL查询来查找两个字段是否相同的记录?也就是说,我可以使用下表,并通过比较名称列(忽略手机)返回1,3(ids)?
Can I use a SQL query to find records where one field is identical in both? That is, can I use the following table and return 1,3 (the ids) by comparing the name columns (and ignoring the phone)?
ID | Name | Phone
1 | Bob | 5555555555
2 | John | 1234567890
3 | Bob | 1515151515
4 | Tim | 5555555555
推荐答案
要获得所有不止一次的名称,您可以执行此语句:
To get all names that exist more than once you can execute this statement:
SELECT Name FROM People GROUP BY Name HAVING COUNT(*)>1;
这篇关于SQL可以查找具有重复记录的记录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文