0

I do not know how to select query recursive..

I have table like this:

idmenu   idparent     Title
  1         0         menu_parent1
  2         1         menu_child2
  3         1         menu_child3
  4         0         menu_parent4
  5         4         menu_child5
  6         4         menu_child6

how do the results like this

  idmenu    idparent          Title
  1       menu_parent1     menu_parent1
  2       menu_parent1     menu_child2
  3       menu_parent1     menu_child3
  4       menu_parent4     menu_parent4
  5       menu_parent4     menu_child5
  6       menu_parent4     menu_child6

anyone help me..thanks

1 Answer 1

2

zero doesnt refer to something, can you fix it? the answer may be like this

SELECT aa.idmenu,
       bb.title AS idparent,
       aa.title 
FROM [yourtablename] aa
     LEFT OUTER JOIN [yourtablename] bb 
                  ON aa.idmenu=bb.idmenu
Sign up to request clarification or add additional context in comments.

1 Comment

Its 0 to determine the child's parents.. and it only exists in one table..sorry my english is bad

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.