I have three table
CMS_MenuMaster
ID MenuName MenuDesc ParentID DisplayOrder
1 Product -- 0 1
2 ABC -- 1 2
3 DEF -- 1 3
4 Home -- 0 2
5 Service -- 0 3
EE_RightMaster
RightID RightCode RightDesc
1 Product 1
2 Home 4
3 Service 5
EE_GroupRights
GroupRightID GroupID RightID
1 3 1
Create Procedure SpGetAllMenus
@GroupID int
as
begin
select t3.ID, t3.MenuName, t3.DisplayOrder, t3.Disable, t3.MenuDesc,t3.ParentID,
(select IsNull(MenuName,'') from CMS_MenuMaster where ID = t3.ParentID) as ParentMenu,
from EE_GroupRights t1
inner join EE_RightMaster t2 on t1.RightID = t2.RightID
inner join CMS_MenuMaster t3 on t3.ID = cast(t2.RightDesc as int)
where t1.GroupID = @GroupID
end
for groupid 3 it giv