Re: Union Clause
Date: Mon, 5 May 2008 06:46:35 -0700 (PDT)
Message-ID: <01ce3f07-9621-4920-b1b9-c254b2fa7130@p25g2000hsf.googlegroups.com>
On May 5, 9:17 am, Mtek <m..._at_mtekusa.com> wrote:
> Hi,
>
> This is my query:
>
> SELECT SUM(zcom) + SUM(ze) + SUM(zp)
> FROM
> (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom
> UNION
> (SELECT count(DISTINCT(email)) FROM customers_lookup) ze
> UNION
> (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp);
>
> Basically I want to get a count from the three tables where the email
> address appears in ALL THREE tables. If an email does not exist in
> all three tables, then I do not want it counted.......
>
> I think I'm barking up the wrong tree with the query above......
>
> John.
But you show only one table in this query, customers_lookup.
Here's a hint in the form of a question: What is the difference between the union operation and the join operation?
hth,
ed
Received on Mon May 05 2008 - 08:46:35 CDT