Re: combining - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: combining
Date
Msg-id Pine.LNX.4.30.0102121959220.1100-100000@peter.localdomain
Whole thread Raw
In response to combining  ("Frank Morton" <fmorton@base2inc.com>)
List pgsql-sql
Frank Morton writes:

> These two queries get me what I want from each table:
>
> select unique id from table1 where lastname='morton';
> select unique id from table2 where ((type = "pie") and (content = 'apple));
>
> What is the best way to combine these into one query?

select table1.id from table1, table2 where table1.id = table2.id and
lastname = 'morton' and type='pie' and content = 'apple';

Or in 7.1, optionally:

select id from table1 natural join table2 where lastname = 'morton' and
type ='pie' and content = 'apple';

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: Re: combining
Next
From: mark proctor
Date:
Subject: Re: Recusrive Functions in 7.0.3