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 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-05 : 11:42:03
|
| Hi,How do you express neither no in TSQL. I am trying to create a view that gathers work orders that are neither in one table nor in anotherI tried the following few appraoches but feel there must be something better. thanks!1.Select *FROM xyzWHERE Status = Open AND (Number NOT IN (SELECT WONumber FROM dbo.Table1) OR Number NOT IN (SELECT WONumber FROM dbo.Table2))2.Select *FROM xyzWHERE Status = Open AND Number NOT IN (SELECT WONumber FROM dbo.Table1)UNIONSelect *FROM xyzWHERE Status = Open AND Number NOT IN (SELECT WONumber FROM dbo.Table2) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-05 : 11:47:04
|
| [code]SELECT t.*FROM xyz tLEFT JOIN dbo.Table1 t1ON t1.WONumber=t.NumberLEFT JOIN dbo.Table2 t2ON t2.WONumber=t.NumberWHERE t.Status = 'Open'AND t1.WONumber IS NULLAND t2.WONumber IS NULL[/code] |
 |
|
|
|
|
|