rain13 Posted July 15, 2014 Share Posted July 15, 2014 Hellosuppose I have following table 'forums'forumId, parentId, Name1, 0, chat2, 1, pets3, 1, biking4, 2, catsMeaning that pets is subforum of chat and cats is sub forum of pets.To get In PHP I would call GetParent() until parentId gets 0. which would run mysql_query() 3 times to get path for cats.The path would be chat => pets => catsI was wondering if it is possible to write single SQL query to get such path? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 21, 2014 Share Posted July 21, 2014 There are ways to design a database so that you can do that, the design that you have won't let you get that data with a single query.https://www.google.com/search?client=opera&q=database+design+tree+structure&sourceid=opera&ie=UTF-8&oe=UTF-8 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now