Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 3C8799F9D99 for ; Tue, 3 Oct 2006 04:54:43 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 00778-08 for ; Tue, 3 Oct 2006 07:54:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from web53507.mail.yahoo.com (web53507.mail.yahoo.com [206.190.37.68]) by postgresql.org (Postfix) with SMTP id CD1249F9312 for ; Tue, 3 Oct 2006 04:54:39 -0300 (ADT) Received: (qmail 38016 invoked by uid 60001); 3 Oct 2006 07:54:37 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=LMMBY0S2XB1EZ5vQZHMUJraKPmAD3Lec/FGfeF3kwuyeV+4XVg/NT+Njw/EBEBBV27qiLg2vtDf6WWw4XWnO/1iX6djckje4+D7NriwB7yl6VRlql6X3w+hv5rGCqwfBrRw40fBeMd+BGSeOFrki8vTrUfzXtW5/FdJtEzbCHSM= ; Message-ID: <20061003075437.38014.qmail@web53507.mail.yahoo.com> Received: from [196.38.142.117] by web53507.mail.yahoo.com via HTTP; Tue, 03 Oct 2006 00:54:37 PDT Date: Tue, 3 Oct 2006 00:54:37 -0700 (PDT) From: Allan Kamau Subject: [SQL Question] Selecting distinct rows having field value pairs on semantics To: pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.355 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: *** X-Archive-Number: 200610/11 X-Sequence-Number: 23314 Hi all, I am looking for a way of selecting records from a table comprising of pairing fields having unique semantics, where the pair of values of lets say 'left' and 'right' and another pair having values of 'right' and 'left' is considered as duplicates as they have the same meaning. Below is my table structure. create table ppi_edges_tf ( tf_id1 char(6)not null, tf_id2 char(6)not null, primary key(tf_id1,tf_id2) ); I would like to create a query on this table that will contain only unique [tf_id1 and tf_id2] combination is unique semantically. for example looking at a select rows of the table tf_id1 | tf_id2 -------+-------- T00111 | T00111 T00111 | T00112 T00111 | T01400 T00111 | T05015 T00112 | T00111 The second record (T00111 | T00112) and the fifth record(T00112 | T00111) have the same pairing meaning and should be considered duplicate in my case and only one for the records (either one) should be contained in the desired resultset of unique values. The desired resultset could be something like this tf_id1 | tf_id2 -------+-------- T00111 | T00111 T00111 | T00112 T00111 | T01400 T00111 | T05015 Allan. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com