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 |
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2008-12-01 : 07:54:56
|
| HiI have 3 tables that looks like this...[tbl_Menu]NodeID IntParentNodeID IntText nVarchar[tbl_MenuAccess]CustID IntNodeID IntIsActive Int[tbl_UserMenuAccess]UID IntNodeID IntIsActive Inttbl_Menu hold the actual information about the different menu's.tbl_MenuAccess holds the all available menu's for a customer.tbl_UserMenuAccess holds the different NodeID's that the current client have access to.tbl_MenuAccess have 10 different rows like this..NodeID CustID IsActive1 1 12 1 03 1 14 1 15 1 16 1 17 1 18 1 19 1 010 1 1And tbl_UserMenuAccess have these rowsUID NodeID IsActive5 1 1Now I would like to display all items for the selected customer (CustID = 1) and selected user (UID = 5). So even if UID = only have access to NodeID = 1 the result should display all 10 rows that are available for CustID 1, but if a record is in tbl_MenuAccess and not in tbl_UserMenuAccess then it should be flagged as disabled.This seems like it should be an easy task but I cannot get it to work, I only get the one record that exsits in tbl_UserMenuAccess.. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-01 : 09:07:06
|
| [code]SELECT *,CASE WHEN uma.NodeID IS NOT NULL THEN 'Active' ELSE 'DisAbled' ENDFROM [tbl_MenuAccess] maLEFT JOIN [tbl_UserMenuAccess] umaON uma.NodeID=ma.NodeIDAND uma.UID=@UIDWHERE CustID=@CustID[/code]@UID,@CustID are parameters through which you pass values (5 & 1 in your case) |
 |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2008-12-01 : 09:27:06
|
| This was just what I wanted, Thank you very much! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-01 : 09:28:29
|
You're welcome glad that i could help you out |
 |
|
|
|
|
|