Re: [SQL] self-join and DISTINCT quandry.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] self-join and DISTINCT quandry.
Дата
Msg-id 5276.938647349@sss.pgh.pa.us
обсуждение исходный текст
Ответ на self-join and DISTINCT quandry.  (Stuart Rison <rison@biochemistry.ucl.ac.uk>)
Ответы Re: [SQL] self-join and DISTINCT quandry.  (Stuart Rison <rison@biochemistry.ucl.ac.uk>)
Список pgsql-sql
Stuart Rison <rison@biochemistry.ucl.ac.uk> writes:
> But what is I didn't want the information to appear twice.  I could try
> adding DISTINCT but that would not work because row a,1,7 is of course
> DISTINCT from a,7,1 although I am looking for such duplication to be
> eliminated...

Bit of a hack, but you could add the condition... AND t1.number < t2.number;
to get rid of the two-way duplication that otherwise arises from
your join.  (Any other way of selecting just one of the pair
of matches would work as well, of course; you could compare the
two row's OIDs if nothing else was handy.)

Not sure if you still need DISTINCT after that.
        regards, tom lane


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

Предыдущее
От: "Ismail Kizir"
Дата:
Сообщение:
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Date: Wed, 29 Sep 1999 23:49:15 +0300