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

From: "Fay Du" <fay(dot)du(at)versaterm(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: How can I selet rows which have 2 columns values cross equal?
Date: 2006-03-10 13:24:44
Message-ID: 001d01c64445$fec23350$b8d849c6@versaterm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Milorad Poluga 2006-03-10 14:27:41 Re: How can I selet rows which have 2 columns values cross equal?
Previous Message Markus Schaber 2006-03-10 13:12:06 Re: dbLink Query