Re: Difference between IN and JOIN

Поиск
Список
Период
Сортировка
От Markus Bertheau
Тема Re: Difference between IN and JOIN
Дата
Msg-id 1096899829.2651.13.camel@dicaprio.akademie1.de
обсуждение исходный текст
Ответ на Re: Difference between IN and JOIN  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
В Пнд, 04.10.2004, в 16:17, Tom Lane пишет:
> Markus Bertheau <twanger@bluetwanger.de> writes:
> > I lately wondered if there is a difference between a JOIN and a IN in
> > queries similar to the following:
>
> > SELECT f1 FROM t1 JOIN t2 ON (t.f2 = t2.f2) WHERE t2.f3 = x
>
> > SELECT f1 FROM t1 WHERE t1.f2 IN (SELECT f2 FROM t2 WHERE f3 = x)
>
> > As I see it there's no semantic difference between the two.
>
> There's plenty of difference, if t2 contains repeated occurrences of f2
> values.

In my case f2 is the primary key of t2. I probably didn't state the
point of my question well enough: You can write an IN query as a
semantically equal JOIN. I wondered, which one I should prefer, and on
which grounds.

Thanks

--
Markus Bertheau <twanger@bluetwanger.de>



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Difference between IN and JOIN
Следующее
От: "C. Bensend"
Дата:
Сообщение: Stuffing six separate columns into a single array?