I have 3 tables in a mysql database: categories, lists, and items with the following fields:
Categories: id, label
Lists: id, cat_id, label, weight
Items: id, list_id, label, weight, status
I would like to retrieve results from the database so that items will be returned in the following structure, so that the items will be stored in arrays under their respective lists, and lists will be stored in arrays under their respective categories, such as:
Category 1
----- List 1
---------- Item 1
---------- Item 2
---------- Item 3
----- List 2
---------- Item 1
---------- Item 2
---------- Item 3
Category 2
----- List 1
---------- Item 1
---------- Item 2
---------- Item 3
----- List 2
---------- Item 1
---------- Item 2
---------- Item 3
I believe this can be done with a single query - could someone please post a query that would achieve this?
Thank you!