Re: combining

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Frank Morton <fmorton(at)base2inc(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: combining
Date: 2001-02-12 19:01:32
Message-ID: Pine.LNX.4.30.0102121959220.1100-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://yi.org/peter-e/

In response to

  • combining at 2001-02-12 18:20:19 from Frank Morton

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-02-12 21:17:05 Re: ORDER BY in SQL functions
Previous Message Jie Liang 2001-02-12 18:46:11 Re: combining