From: Jie Liang <jliang@ipinc.com>
To: Frank Morton <fmorton@base2inc.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: combining
Date: Mon, 12 Feb 2001 10:46:11 -0800 (PST)
Message-ID: <Pine.BSF.4.10.10102121038390.23715-100000@tidal.ipinc.com> (raw)
In-Reply-To: <012501c09520$74e7bc10$8455e5ce@edison>
Jie LIANG
St. Bernard Software
Internet Products Inc.
10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873
jliang@ipinc.com
www.stbernard.com
www.ipinc.com
On Mon, 12 Feb 2001, Frank Morton wrote:
> I'll really appreciate help on this if anyone will do so. I'm
> used to single-table stuff, but not sure the best way to
> do things with multiple tables, but here goes:
>
> Given two tables with a common "id" field, first table columns:
>
> id
> lastname
>
> Second table columns:
>
> id
> type
> content
>
> 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));
it depends what you want:
1.
select id from table1 where lastname='morton' and id=table2.id
and table2.type = 'pie' and table2.content ='apple';
will return you the id in the intersection of 2 sets.
2.
select id from table1 where lastname='morton' union
select id from table2 where ((type = 'pie') and (content =
'apple'));
will return you a set1+set2;
>
> What is the best way to combine these into one query?
>
> Thanks.
>
> Frank
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jliang@ipinc.com, fmorton@base2inc.com
Subject: Re: combining
In-Reply-To: <Pine.BSF.4.10.10102121038390.23715-100000@tidal.ipinc.com>
References: <012501c09520$74e7bc10$8455e5ce@edison> <Pine.BSF.4.10.10102121038390.23715-100000@tidal.ipinc.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox