regicidedelferoz Posted September 19, 2012 Share Posted September 19, 2012 (edited) good day everyone! i have a question about Managing Hierarchical Data in MySQL of mike hillyer (http://mikehillyer.c...-data-in-mysql/) i already did what he taught in that website and this is the result of the query but i want to do is to show all categories in one column order by categories.. for example:category 1- category 1.1-- category 1.1.1-- category 1.1.2- category 1.2-- category 1.2.1...category 3category 4and so on thanks in advancemore power Edited September 20, 2012 by Regicide Del Feroz Link to comment Share on other sites More sharing options...
regicidedelferoz Posted September 19, 2012 Author Share Posted September 19, 2012 anyways this is the query i used SELECT t1.title AS lev1, t2.title as lev2, t3.title as lev3, t4.title as lev4FROM tbl_news2_cat AS t1LEFT JOIN tbl_news2_cat AS t2 ON t2.parent_category = t1.idLEFT JOIN tbl_news2_cat AS t3 ON t3.parent_category = t2.idLEFT JOIN tbl_news2_cat AS t4 ON t4.parent_category = t3.idWHERE t1.parent_category=0 Link to comment Share on other sites More sharing options...
justsomeguy Posted September 19, 2012 Share Posted September 19, 2012 Assuming you want to order the categories in a heirarchical order instead of alphabetically, you can't do that with a single query with the adjacency list model. The common way to do that would be to use another language like PHP to implement a recursive function that displays categories and their children. Link to comment Share on other sites More sharing options...
regicidedelferoz Posted September 20, 2012 Author Share Posted September 20, 2012 i see. but i already tried to do it with php and it's working well. but my problem now is the pagination. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 20, 2012 Share Posted September 20, 2012 What's the problem with pagination? 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