Re: [SQL] Duplicate rows

Поиск
Список
Период
Сортировка
От Oleg Broytmann
Тема Re: [SQL] Duplicate rows
Дата
Msg-id Pine.LNX.3.96.SK.980516175721.21932B-100000@torus.comus.ru
обсуждение исходный текст
Ответ на Re: [SQL] Duplicate rows  (Andy Lewis <alewis@mpsi.net>)
Ответы Re: [SQL] Duplicate rows
Список pgsql-sql
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@earthling.net
           Programmers don't die, they just GOSUB without RETURN.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Andy Lewis
Дата:
Сообщение: Re: [SQL] Duplicate rows
Следующее
От: Bruce Stephens
Дата:
Сообщение: Re: [SQL] Duplicate rows