Re: Select from multiple tables

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: Select from multiple tables
Дата
Msg-id Pine.LNX.4.33.0306061259390.20091-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Select from multiple tables  (Jon Earle <je_pgsql@kronos.honk.org>)
Список pgsql-general
On Fri, 6 Jun 2003, Jon Earle wrote:

> Hi,
>
> I want to select data from two tables, with the keying information for the
> second table coming from the select results of the first.  Can this be
> done in one call, or will I need to resort to two calls - one to get the
> record from the first table, then a second call to get the record from the
> second table based on a key contained in the first results set?

You probably want a join or a sub select.

select * from table1 t1 left join table2 t2 on (t1.id=t2.t1id);

select * from table1 where id in (select id from table2 where compid=3);

Or is it more complex than that?


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

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Bug in metaphone (contrib/fuzzystrmatch)
Следующее
От: Ian Barwick
Дата:
Сообщение: Re: update phenomenom