SQL中查找某几个字段完全一样的数据

有以下一个表

movestar(id,name,title,address),内容为:

https://www.dbs724.com/wp-content/uploads/2023/02/1676892128-80efaea75b7db73.jpg

现在要查找所有具有相同的title和address的人

select star1.name,star2.name,star1.title,star1.address
from movestar as star1,movestar as star2
where star1.title = star2.title
    and star1.address = star2.address
    and star1.name < star2.name;

结果:

https://www.dbs724.com/wp-content/uploads/2023/02/1676892129-4ab2c5039cd0300.jpg

要点:使用了<,假如用<>则会将内容重复列出

本篇文章到此结束,如果您有相关技术方面疑问可以联系我们技术人员远程解决,感谢大家支持本站!


数据运维技术 » SQL中查找某几个字段完全一样的数据