Recurrent Query

  • Hi guys,

    I will explain the situation here since I think it's really complicated.

    I have a main menu with 10 options. If I select any option, there is another menu with lets say 5 options. Again this 5 options will have underneath other menus.

    This flow: main menu - submenu - submenu -submenu... will end where the option selected will execute something and there is no menu underneath.

    I managed to get the data in the following format

    ID int

    Menu char(100)

    MenuText char(250)

    SubMenu char(100)

    Where you will find the values for the submenu in the menu field

    I will add some values for more clarification

    1    a     test1    a1

    2    a     test2    a2

    3    a     test3    a3

    4    a     test4    a4

    5    b     test5    b1

    6    a1    test6   a11

    7    a1    test7   a12

    8    a11  test8  

    9    b1    test9   b11

    10  a12  test10  

    ...

    What I'm trying to achieve is to get all the submenus for example for menu 'a'

    So the results are going to be a1, a2, a3, a4, a11, a12

    The submenus are ending on line 8 and 10 because they don;t have any records in the submenu field.

    Any suggestion how to solve this query?

    Thank you

  • Do a search on "Trees in SQL" "Nested Sets" or Expanding Hierarchies on this site or google, you will get lots of info.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply