regicidedelferoz 0 Posted September 19, 2012 Report 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 Quote Link to post Share on other sites
regicidedelferoz 0 Posted September 19, 2012 Author Report 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 Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 19, 2012 Report 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. Quote Link to post Share on other sites
regicidedelferoz 0 Posted September 20, 2012 Author Report 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. Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 20, 2012 Report Share Posted September 20, 2012 What's the problem with pagination? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.