From: Ben Kim <bkim@tamu.edu>
To: Richard Broersma <richard.broersma@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: compare two rows
Date: Tue, 12 Oct 2010 17:10:55 -0500
Message-ID: <20101012221055.GC985@tamu.edu> (raw)
In-Reply-To: <AANLkTinpScsTqJwiM_=3=PN+jjdvHrR8RTdWToA_iP7P@mail.gmail.com>
References: <AANLkTimX4BNmUm7KJ72FUBu+FgcKDxZdMcK4FkTfOmwA@mail.gmail.com>
<4CB479DB02000025000368A9@gw.wicourts.gov>
<20101012201747.GA720@tamu.edu>
<AANLkTinpScsTqJwiM_=3=PN+jjdvHrR8RTdWToA_iP7P@mail.gmail.com>
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 <bkim@tamu.edu> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: bkim@tamu.edu, richard.broersma@gmail.com
Subject: Re: compare two rows
In-Reply-To: <20101012221055.GC985@tamu.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox