Re: [SQL] Duplicate rows

From: Andy Lewis <alewis(at)mpsi(dot)net>
To: phd2(at)earthling(dot)net
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Duplicate rows
Date: 1998-05-16 14:10:06
Message-ID: Pine.LNX.3.95.980516090952.15079C-100000@shell.mpsi.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks, I'll give it a try.

Andy

On Sat, 16 May 1998, Oleg Broytmann wrote:

>Hi!
>
>On Sat, 16 May 1998, Andy Lewis wrote:
>> Right, I know that there are dups in the column. But, I don't know where they
>> are nor do I know their value(s). I want to be able to find, say, two interger
>> values that are in the same column but, different rows.
>
> It seems that you need a correlated subquery - a loop for every row, that
>tests whether there are equal values.
>
>SELECT oid, mycolumn FROM mytable a
> WHERE mycolumn IN
> (SELECT oid, mycolumn FROM mytable b
> WHERE a.oid <> b.oid)
>
>Or may be, join with the same table. Not sure what is better in this
>situation.
>
>SELECT oid, mycolumn FROM mytable a, mytable b
> WHERE a.oid <> b.oid AND
> a.mycolumn = b.mycolumn
>
> In both cases "a.oid <> b.oid" excludes the same row from comparison (I
>am pretty sure that in the same row a.mycolumn = b.column :).
>
>Oleg.
>----
> Oleg Broytmann http://members..tripod.com/~phd2/ phd2(at)earthling(dot)net
> Programmers don't die, they just GOSUB without RETURN.
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Perry Seleski 1998-05-18 07:48:30 primary keys
Previous Message Oleg Broytmann 1998-05-16 14:06:06 Re: [SQL] Duplicate rows