List:General Discussion« Previous MessageNext Message »
From:SGreen Date:January 18 2006 8:24pm
Subject:Re: Help in joining three tables
View as plain text  
"Imran" <imran@stripped> wrote on 01/18/2006 03:13:08 PM:

> 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.
> 
> Best regards
> Imran. 
> 

Assuming INNER JOINs:

SELECT *
FROM table1 t1
INNER JOIN table2 t2
  ON t1.ProdNo = t2.ProdNo
  AND t1.CustNo = t2.CustNo
  AND t1.Branch = t2.Branch
INNER JOIN table3 t3
  ON t1.CustNo = t3.CustNo
  AND t1.Branch = t3.Branch;

If this doesn't fit you needs, you need to describe your situation with 
MORE DETAILS and I or someone else will try again.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
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