Skip to content
Advertisement

MySQL query – join 4 tables together, with 3 tables using group by one column from each

Here are examples of the 4 tables I’m working with.

And I’m trying to get outputs with php foreach something like this …

This is the query I’ve come for one table…

Advertisement

Answer

You can cross join the items table with all available dates in the three other tables, and then the aggregations from the three tables with left joins:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement