X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 3CCE99DC941 for ; Fri, 10 Mar 2006 09:52:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70858-01 for ; Fri, 10 Mar 2006 09:52:49 -0400 (AST) X-Greylist: delayed 00:27:55.310584 by SQLgrey- Received: from smtp.versaterm.com (smtp.versaterm.com [216.208.41.121]) by postgresql.org (Postfix) with ESMTP id 035179DC80C for ; Fri, 10 Mar 2006 09:52:43 -0400 (AST) Received: from fay (unknown [198.73.216.184]) by smtp.versaterm.com (Postfix) with ESMTP id 5956B70003 for ; Fri, 10 Mar 2006 08:24:44 -0500 (EST) From: "Fay Du" To: Subject: How can I selet rows which have 2 columns values cross equal? Date: Fri, 10 Mar 2006 08:24:44 -0500 Message-ID: <001d01c64445$fec23350$b8d849c6@versaterm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200603/147 X-Sequence-Number: 24493 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