sql server - SQL select menus which have no submenu -
i have table in sql server having title, id , refer. refer indicates item submenu of other.
sample table:
id | refer | title
1 | 0 | menu 1
2 | 0 | menu 2
3 | 1 | submenu of 1
4 | 1 | submenu of 1
i need query select items has no submenu (in case menu 2). have solved asp code counts submenus , omits unwanted results need pure sql query.
select t1.* yourtable t1 left join yourtable t2 on t1.id = t2.refer t2.refer null , t1.refer=0
Comments
Post a Comment