View Single Post
  #1 (permalink)  
Old 04-20-2006, 12:23 AM
ben ben is offline
Administrator
 
Join Date: Mar 2007
Posts: 87
ben has disabled reputation
Default ANY dialect question:

How can I selet rows which have 2 columns values cross equal?


This question was initially asked on the postgres.sql mailing list: http://article.gmane.org/gmane.comp.db.postgresql.sql/17005

Hi All:
I have a table like this:

Table test
Id | a | b
-----+----+---
1 | 100| 101
2 | 101| 100
3 | 100| 3
4 | 20 | 30
5 | 11 | 13
6 | 3 | 33
7 | 30 | 20

I want to get row 1, 2,4 and 7 selected. Because their values of a and b
are cross equal. i.e., for each pair of rows,
a.Row1 = b.Row2 and b.Ro1 = a.Row2
a.Row4 = b.Row7 and b.Ro4 = a.Row7

How can I construct a sql statement to select them?
Thanks in advance.
Fay
Reply With Quote

ANSWER(S):