List:General Discussion« Previous MessageNext Message »
From:William R. Mussatto Date:October 18 2006 8:02pm
Subject:Re: Simple JOIN on three tables
View as plain text  
On Wed, October 18, 2006 12:46, spacemarc said:
> Hi
> I have 3 tables with the same fields.
>
> I would want to find the data that they are comprised in the time
> interval:
>
> SELECT a.*, b.*, c.*
> FROM tab1 a, tab2 b, tab3 c
> WHERE a.date between 'YYYY-MM-DD' and 'YYYY-MM-DD'
> OR b.date between 'YYYY-MM-DD' and 'YYYY-MM-DD'
> OR c.date between 'YYYY-MM-DD' and 'YYYY-MM-DD'
> ORDER BY a.date DESC
>
> But this query returns all the fields duplicated.
> Where it is mistaken?
>
> --
> http://www.spacemarc.it
Well that's what you asked it to do, if you look closely at your query.

How are table a, b, and c related to each other?

Do you want all the information from each of the tables (which are NOT
related to each other) between the specified dates?  If that is the case
you are looking at a UNION rather than a strait JOIN.


-------

William R. Mussatto, Senior Systems Engineer
http://www.csz.com
Ph. 909-920-9154 ext. 27
FAX. 909-608-7061

Thread
Simple JOIN on three tablesspacemarc18 Oct
  • Re: Simple JOIN on three tablesWilliam R. Mussatto18 Oct
  • Re: Simple JOIN on three tablesRolando Edwards18 Oct
    • Re: Simple JOIN on three tablesspacemarc18 Oct
      • Re: Simple JOIN on three tablesPeter Brawley18 Oct
        • Re: Simple JOIN on three tablesspacemarc18 Oct
          • Re: Simple JOIN on three tablesWilliam R. Mussatto18 Oct
            • Re: Simple JOIN on three tablesspacemarc18 Oct
          • Re: Simple JOIN on three tablesPeter Brawley18 Oct
      • Re: Simple JOIN on three tablesWilliam R. Mussatto18 Oct
  • Re: Simple JOIN on three tablesMartijn Tonies19 Oct