Re: Select from multiple tables - Mailing list pgsql-general

From scott.marlowe
Subject Re: Select from multiple tables
Date
Msg-id Pine.LNX.4.33.0306061259390.20091-100000@css120.ihs.com
Whole thread Raw
In response to Select from multiple tables  (Jon Earle <je_pgsql@kronos.honk.org>)
List 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 by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Bug in metaphone (contrib/fuzzystrmatch)
Next
From: Ian Barwick
Date:
Subject: Re: update phenomenom