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.
| Author |
Topic |
|
robertc
Starting Member
7 Posts |
Posted - 2011-09-27 : 15:43:12
|
Hi,I have two tables that I'm working with.tblUsers useridtblSheets userid sheetidI'm trying to grab all records from tblUsers regardless if there are entries for that user in tblSheets.SELECT TOP 10240 d.userID,s.userID as inSheet FROM tblUsers u LEFT OUTER JOIN tblSheets s ON u.userID = s.userID WHERE s.sheetid = 676 The code above is only bringing back results where users are actually in the sheetid of 676. But i'd like to bring them all back, and if they are not in sheet 676 then inSheet would contain null. If they were then inList would just have their userID so I could run test in my web app. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-09-27 : 15:45:54
|
| [code]SELECT TOP 10240 d.userID,s.userID as inSheet FROM tblUsers u LEFT OUTER JOIN tblSheets s ON u.userID = s.userID and s.sheetid = 676[/code]Be One with the OptimizerTG |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|