Re: where clauses and multiple tables

Поиск
Список
Период
Сортировка
Искать
От
David W Noon
Тема
Re: where clauses and multiple tables
Дата
Msg-id
20090909000221.36d0c6c9@dwnoon.ntlworld.com
Ответ на
Список
Дерево обсуждения
where clauses and multiple tables Scott Frankel <frankel@circlesfx.com>
Re: where clauses and multiple tables David W Noon <dwnoon@ntlworld.com>
Re: where clauses and multiple tables Yaroslav Tykhiy <yar@barnet.com.au>
Re: where clauses and multiple tables John R Pierce <pierce@hogranch.com>
Re: where clauses and multiple tables David W Noon <dwnoon@ntlworld.com>
Re: where clauses and multiple tables Scott Frankel <frankel@circlesfx.com>
Re: where clauses and multiple tables miller_2555 <nabble.30.miller_2555@spamgourmet.com>
On Tue, 8 Sep 2009 14:25:20 -0700, Scott Frankel wrote about [GENERAL]
where clauses and multiple tables:

>Is it possible to join tables in the where clause of a statement?
[snip]
>Given a statement as follows:
>
>   SELECT foo.foo_id, foo.name
>   FROM foo, bar
>   WHERE foo.bar_id = bar.bar_id
>   AND bar.name = 'martini';

Just use an IN predicate:

 SELECT foo_id, name FROM foo
 WHERE bar_id IN (SELECT bar_id FROM bar WHERE name = 'martini');

This is frequently called a semi-join.
-- 
Regards,

Dave  [RLU #314465]
=======================================================================
david.w.noon@ntlworld.com (David W Noon)
=======================================================================
В списке pgsql-general по дате отправления
От: miller_2555
Дата:
От: miller_2555
Дата:
FAQ