Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 749C11337B82 for ; Tue, 12 Oct 2010 19:11:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 06372-01 for ; Tue, 12 Oct 2010 22:10:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from benix.tamu.edu (ben.tamu.edu [165.91.232.129]) by mail.postgresql.org (Postfix) with ESMTP id 7158A1337B69 for ; Tue, 12 Oct 2010 19:10:56 -0300 (ADT) Received: from benix.tamu.edu (localhost.localdomain [127.0.0.1]) by benix.tamu.edu (8.14.4/8.14.3) with ESMTP id o9CMAtxc001390; Tue, 12 Oct 2010 17:10:55 -0500 Received: (from bkim@localhost) by benix.tamu.edu (8.14.4/8.14.4/Submit) id o9CMAt9j001388; Tue, 12 Oct 2010 17:10:55 -0500 Date: Tue, 12 Oct 2010 17:10:55 -0500 From: Ben Kim To: Richard Broersma Cc: pgsql-admin@postgresql.org Subject: Re: compare two rows Message-ID: <20101012221055.GC985@tamu.edu> References: <4CB479DB02000025000368A9@gw.wicourts.gov> <20101012201747.GA720@tamu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/102 X-Sequence-Number: 35843 Thanks. I'm on 8.4.2. I was not clear but the two rows are from the same table. Here's the test case. create table test_dup (id serial primary key, val text); insert into test_dup(val)values('some text'); insert into test_dup(val)values('some texta'); select * from test_dup; id | val ----+------------ 1 | some text 2 | some texta How can I check whether the two rows are the same or different? Thanks. On Tue, Oct 12, 2010 at 02:12:36PM -0700, Richard Broersma wrote: > On Tue, Oct 12, 2010 at 1:17 PM, Ben Kim wrote: > > Admins, > > > > What is the best way to compare two rows from within psql cli client? > > > > It has ~30 fields, and the two rows are duplicate data but there might > > be differences. > > > > id field1  field2  field3 ... > > =========================== > > id1 value1 value2 value3  ... > > id2 value1 value2 value3  ... > > > > I could write a generic script to iterate through the list of fields and > > compare each field values, or concatenate the fields to a string, but wondered what is out there. > > > > Also, is there a way around to use select row(...) = row(...)? > > Does: (T1.value1,T1.value2, T1.value3, ... ) IS NOT DISTINCT FROM > (T2.value1,T2.value2, T2.value3,...) > or: Row( T1.* ) IS NOT DISTINCT FROM ( T2.* ) > work for you? > > > > > > -- > Regards, > Richard Broersma Jr. > > Visit the Los Angeles PostgreSQL Users Group (LAPUG) > http://pugs.postgresql.org/lapug