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 |
|
sharona
Yak Posting Veteran
75 Posts |
Posted - 2011-09-01 : 10:50:36
|
| im having a bit of trouble with this simple nested query belowi need to find out what funds are not assigned to the usersthe userpermission table has the fund code assigned. the fund table is the lookup table, when i do an outer join i still only get what is assigned to the users. i thought a nested query would work. when i use in i get all the funds assigned, when is use NOT IN i get nothing. any ideas?SELECT FundCode, UserCode, RoleCodeFROM dbo.UserPermissionWHERE FundCode IN (SELECT FundCode FROM Fund)AND UserCode ='NAG' |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-09-01 : 10:52:40
|
[code]select *from Fund fwhere not exists ( select * from UserPermission u where u.FundCode = f.FundCode )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sharona
Yak Posting Veteran
75 Posts |
Posted - 2011-09-01 : 11:06:45
|
| thank you |
 |
|
|
|
|
|