Removing Mirrored Pairs from SQL Join

前端 未结 3 576
遥遥无期
遥遥无期 2021-02-10 19:40

I have a table with 2 fields (name, interest) and I want to find all pairs that have the same interest, with all duplicates and mirrored pairs removed.

I am able to find

3条回答
  •  情话喂你
    2021-02-10 20:06

    I had similar problem and figure out studying the first answer that the query below will do the trick

    SELECT P1.name AS name1,P2.name AS name2,P1.interest 
    FROM Table AS P1,Table AS P2
    WHERE P1.interest=P2.interest AND P1.name>P2.name  
    

提交回复
热议问题