List:General Discussion« Previous MessageNext Message »
From:Rhino Date:January 18 2006 10:28pm
Subject:Re: Help in joining three tables
View as plain text  
----- Original Message ----- 
From: <SGreen@stripped>
To: "Rhino" <rhino1@stripped>
Cc: "Imran" <imran@stripped>; <mysql@stripped>
Sent: Wednesday, January 18, 2006 5:07 PM
Subject: Re: Help in joining three tables


> "Rhino" <rhino1@stripped> wrote on 01/18/2006 03:30:44 PM:
>
>>
>> ----- Original Message ----- 
>> From: "Imran" <imran@stripped>
>> To: <mysql@stripped>
>> Sent: Wednesday, January 18, 2006 3:13 PM
>> Subject: Help in joining three tables
>>
>>
>> > Hello All:
>> >
>> > I need to join three tables but I am not sure how to structure the
> query.
>> > I need to join table1 to table2 and then join table3 to this result
> set.
>> >
>> > So like (table1 join table2) join table3.
>> >
>> > Table1 and Table2 will be joined on ProdNo,CustNo and Branch. Table3
> will
>> > be
>> > joined to the result set by CustNo and Branch.
>> >
>> There are many types of joins: inner joins, left joins, right joins,
> cross
>> joins, etc. I don't know which types you want to do so I'll just assume
>> inner joins and let you modify my answer to suit your basic needs.
>>
>> Select t1.col1, t1.col3, t3.col5, t2.col9
>> from table1 t1 join table t2 on t1.col1 = t2.col4
>> join table3 t3 on t3.col5 = t1.col8
>> where t2.country = 'USA'
>> and t3.planet = 'EARTH'
>> order by t1.col1, t2.col2;
>>
>> Rhino
>>
>
>
> Rhino?
>
> What does your example have to do with the tables and columns or the
> relationships between them provided for you in the original post?
>
> Just curious....
>

There's no real relationship at all, actually :-) I just conjured up an 
untested example. I suppose I should have worked Imran's column names into 
the table instead of using my own - or at least explained what I was doing 
more clearly.

Sorry for any confusion! I'm afraid I'm a bit distracted today so forgive me 
for a weak example.

Rhino 



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 18/01/2006

Thread
Procedure / Prepared statements error converting tableDan Burke18 Jan
  • Re: Procedure / Prepared statements error converting tableSGreen18 Jan
    • Help in joining three tablesImran18 Jan
      • Re: Help in joining three tablesSGreen18 Jan
      • Re: Help in joining three tablesgerald_clark18 Jan
      • Re: Help in joining three tablesRhino18 Jan
        • Re: Help in joining three tablesSGreen18 Jan
          • Re: Help in joining three tablesRhino18 Jan
  • Re: Procedure / Prepared statements error converting tablePeter Brawley18 Jan
RE: Procedure / Prepared statements error converting tableDan Burke18 Jan