Remove reverse duplicates from an SQL query

前端 未结 2 402
囚心锁ツ
囚心锁ツ 2020-12-05 15:06

Let\'s say that a query result is supposed to return a list of string pairs (x, y). I am trying to eliminate the reverse duplicates. What I mean is, if (x, y) was one of the

2条回答
  •  心在旅途
    2020-12-05 15:57

    select e.column3, f.column3 from example as e, example as f where e.column2 = f.column2
           and e.column3 <> f.column3 where e.id < f.id
    

    adding a simple where clause should do it.

提交回复
热议问题