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 |
|
mikedp
Starting Member
2 Posts |
Posted - 2010-04-19 : 08:12:53
|
| Hi,Let's say I have a table with Categories, and a table with Subjects that contain a CategoryID.How can I get a list of Category records that do not have a Subject record linked to them?TnxMike |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-04-19 : 08:14:46
|
| select c.* from categories c left join subjects s on s.CategoryID = c.CategoryIDwhere s.CategoryID is null |
 |
|
|
mikedp
Starting Member
2 Posts |
Posted - 2010-04-19 : 09:10:33
|
| Tnx! That's it. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-19 : 10:56:26
|
| or select c.* from categories c where not exists(select 1 from subjects where CategoryID = c.CategoryID)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-04-20 : 00:36:07
|
quote: Originally posted by mikedp Tnx! That's it.
welcome |
 |
|
|
|
|
|