Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 two left outer join in a single query

Author  Topic 

sonytr
Starting Member

10 Posts

Posted - 2007-12-12 : 15:41:39
How to use two left outer join in a single query?

I was trying to run the follwoing query.It is giving me error

"select woancestor.wonum,wplabor.laborcode, wplabor.quantity,wplabor.laborhrs
from wplabor,workorder left outer join woancestor on workorder.wonum=woancestor.wonum
and wplabor left outer join labtrans on wplabor.laborcode=labtrans.laborcode
where woancestor.ancestor='572099' and workorder.istask=1
and workorder.wonum=wplabor.wonum"

Error is "Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'left'."

But the following query works fine

"select woancestor.wonum,wplabor.laborcode, wplabor.quantity,wplabor.laborhrs
from wplabor,workorder left outer join woancestor on workorder.wonum=woancestor.wonum
where woancestor.ancestor='572099' and workorder.istask=1
and workorder.wonum=wplabor.wonum"

please help me

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-12-12 : 15:44:00
select woancestor.wonum,wplabor.laborcode,wplabor.quantity,wplabor.laborhrs
from wplabor
inner join workorder on workorder.wonum=wplabor.wonum
left outer join woancestor on workorder.wonum=woancestor.wonum
left outer join labtrans on wplabor.laborcode=labtrans.laborcode
where woancestor.ancestor='572099' and workorder.istask=1


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sonytr
Starting Member

10 Posts

Posted - 2007-12-12 : 15:50:14
Thanks you.its working
Go to Top of Page
   

- Advertisement -