Monday, November 18, 2013

MySQL Organize Hierarchical Query Result

Hierarchical data in MySQL is quite simple but the tricky part is manipulating the result in organize manner through SQL query. for example how to arrange the result by placing all child under its parent...

Example:
Table
Original Data from hierarchical table
SELECT *FROM hierarchical


Expected Output:
As we can see all colors arranged under the topic COLOR as well as FRUIT and NUMBER. perhaps there are many possible ways in doing it and I would like to share with you guys my simple SQL construction.
Solution:

Original Output

No comments:

Post a Comment