繁体   English   中英

SQL - 如何 select 行具有相同的 ID 值,其中所有其他列值也相同

[英]SQL - How to select rows with the same ID values where all other column values are also identical

我在标题中找不到上述问题的答案。

我需要 select 所有具有相同 ID的行和所有其他列值也必须相同 该表由 20 列组成。

任何建议将不胜感激。 非常感谢。

这个怎么样

select id, name, ...other fields
from my_table
where id in (
    Select id, count(id)
    from my_table
    group by id, name, ...other fields
    having count(id) > 1
)

相应地更改 group by 和 where 条件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM