簡體   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