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 |
sureshsmanian
Starting Member
31 Posts |
Posted - 2013-03-26 : 12:13:42
|
Hi,I have two tablesMenu----Id : bigintMenuId : bigintMenuName : nvarchar(100)Role----Id : bigintRoleId : nvarchar(20)MenuId : biging (references Menu Table)ReadRole : bitWriteRole : bitDeleteRole : bitI would require to display the list of records based on the following format and conditionsformat:MenuName ReadRole WriteRole DeleteRole------------------------------------------------------------------------------------------------conditions: 1) display the matching rows from role table for the given roleid 2) display the non-existing rows from role table for given roleid Example : For the given roleId='R001' matching rows(first two rows), remaining rows are non-matching rows (ie) For this role remaining menus from Menu tableMenuName ReadRole WriteRole DeleteRole------------------------------------------------Home True True TrueInventory True False FalseHRMS NULL NULL NULL Accounts NULL NULL NULL-------------------------------------------------- Thanks for your help.RegardsSSM |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-26 : 14:28:32
|
something likeSELECT m.MenuName,r.ReadRole,r.WriteRole,r.DeleteRoleFROM Menu mLEFT JOIN Role rON r.MenuId = m.MenuIdAND r.RoleId='R001' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|