Finding rows with same values in multiple columns

前端 未结 2 1633
情书的邮戳
情书的邮戳 2020-12-13 09:50

I am trying to find rows that have duplicate values, but only based off of a select number of columns, not a single column or the entire row. For example, if my table looked

2条回答
  •  [愿得一人]
    2020-12-13 10:02

    Try the following:

    SELECT A.*
    FROM YourTable A
    INNER JOIN (SELECT Address, State
                FROM YourTable
                GROUP BY Address, State
                HAVING COUNT(*) > 1) B
    ON A.Address = B.Address AND A.State = B.State
    

提交回复
热议问题