robstevens
IS-IT--Management
Hi,
I'm having trouble putting together a query in ms sql, could someone point me in the right direction.
Want I have is one table in this format;
menu | submenu
----------------------
menu1 | submenu1
menu2 | submenu2
menu3 | submenu3
menu3 | submenu5
submenu1 | submenu4
submenu2 | submenu4
submenu5 | submenu6
submenu3 | submenu4
submenu4 | BLANK
submenu6 | BLANK
It holds a menu system and shows, for example menu1 has options of submenu1, submenu1 has options of submenu4 and submenu4 has no further menus.
What I need is a query to list the submenu's a particular menu has underneath it.
e.g.
If I gave the query the following input-- ('menu1', 'menu2', 'menu3')
It would return this;
menu1 submenu1
menu1 submenu4
menu2 submenu2
menu2 submenu4
menu3 submenu3
menu3 submenu4
menu3 submenu5
menu3 submenu6
As there can be any nnumber of submenus to a menu I cannot work out how to get the sql to looping over the table. Any help/ideas greatly appreciated.
Cheers.
I'm having trouble putting together a query in ms sql, could someone point me in the right direction.
Want I have is one table in this format;
menu | submenu
----------------------
menu1 | submenu1
menu2 | submenu2
menu3 | submenu3
menu3 | submenu5
submenu1 | submenu4
submenu2 | submenu4
submenu5 | submenu6
submenu3 | submenu4
submenu4 | BLANK
submenu6 | BLANK
It holds a menu system and shows, for example menu1 has options of submenu1, submenu1 has options of submenu4 and submenu4 has no further menus.
What I need is a query to list the submenu's a particular menu has underneath it.
e.g.
If I gave the query the following input-- ('menu1', 'menu2', 'menu3')
It would return this;
menu1 submenu1
menu1 submenu4
menu2 submenu2
menu2 submenu4
menu3 submenu3
menu3 submenu4
menu3 submenu5
menu3 submenu6
As there can be any nnumber of submenus to a menu I cannot work out how to get the sql to looping over the table. Any help/ideas greatly appreciated.
Cheers.