I have three tables: projects, lists, items.
The project joins to the lists on project_id, and the items join to the lists on list_id, and the goal is to have all of the row data for each.
What have I tried?
Well, I actually have only been able to do it by having three separate queries / outputs and then just iterating through them with PHP to combine data.
Is it possible to write the query so that way I end up with one data object that I can easily iterate through?
project (w details)
-- list (and its details)
----- item (w details)
----- item (w details)
----- item (w details)
-- list (w details)
----- item (w details)
----- item (w details)
You mean like this:
Output will be something like:
Or did you want to return all the parts of it in a single row?
If you want a single row, you can do something along the lines of:
But it will get messier in PHP to deal with all the grouped stuff.
Output will be something like:
You could also mix and match the two to maybe get the best of both worlds:
Output will be something like: