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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 outer join not working with AND

Author  Topic 

pelicanPaul
Starting Member

14 Posts

Posted - 2008-08-06 : 20:48:04
There are 7 ACTIVE business units but I am unable to show them all

SELECT b.name
from business_units b
left outer join REQUEST_FORM r on b.id = r.BusinessUnitID
where b.active = 1 and r.userid = 8
group by b.name
order by b.name

and it all revolves around the AND that is bolded above. Not sure how the rewrite this

ideas?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-06 : 21:03:05
Try this:

SELECT b.name
from business_units b
left outer join REQUEST_FORM r
on b.id = r.BusinessUnitID and r.userid = 8
where b.active = 1
group by b.name
order by b.name

Check this out for more information:
http://www.sqlteam.com/article/additional-criteria-in-the-join-clause


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

pelicanPaul
Starting Member

14 Posts

Posted - 2008-08-06 : 21:18:55
thanks a ton!
Go to Top of Page
   

- Advertisement -