Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to do a left outer join on more than three tables?

Status
Not open for further replies.

HeatherB

Programmer
Apr 30, 2006
1
US
Hi,
I'm trying to combine more than three tables with a left outer join. There is only one table with a one relationship to four other tables that have a many relationship to the parent table. I found this syntax:

select * from
(bdg left outer join res on bdg.bid = res.bid)
left outer join dom on bdg.rid = dom.rid ;

and am trying to apply this syntax to more than three tables by doing this:

select * from
(((bdg left outer join res on bdg.bid = res.bid)
left outer join dom on bdg.rid = dom.rid) left outer join room on bdg.bid = room.rid);

but this syntax doesn't seem to work. I'm getting this error: "An unexpected token "END-OF-STATEMENT" was found".

Is my syntax wrong or is it not possible to do a left outer join on more than three tables?

Thank you.
Heather
 
I have just tried 4 tables, with no problem on AIX with DB2 V8.2. The main difference is that I did not use any brackets.

The problem could be the inclusion of the semi-colon if you are running from the command line - it usually is not needed.

Brian
 
Your syntax looks correct to me. I don't think your parenthesis are causing your problem, but you may want to try the following just in case:

select * from bdg
left join res on bdg.bid = res.bid
left join dom on bdg.rid = dom.rid
left join room on bdg.bid = room.rid;

The parenthesis are optional in most cases.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top