I need to return data from two tables this way
Array(
[0] => Array(
[Name] => lorem,
[Qty] => 2),
[1] => Array(
[Name] => ipsum,
[Qty] => 1),
[2] => Array(
[Name] => dolor,
[Qty] => 0)
)
PHP will only take care of getting the data, there will be no manipulation to organize it. Two tables, one to record a certain event, the date and the id of a table related to the event. And the tables are like this:
tableA
id | date | tableB_id
1 2020-10-02 2
1 2020-10-19 2
1 2020-10-21 1
1 2020-11-2 3
1 2020-11-11 1
tableB
id | name
1 lorem
2 ipsum
3 dolor
And my SQL query
SELECT b.name as Name, a.created_at as created
FROM tableA b
INNER JOIN tableA a ON b.tableA_id = a.id WHERE MONTH(b.created_at) = '10' ORDER BY a.id;
which results in
Name | created
ipsum 2020-10-02
ipsum 2020-10-19
lorem 2020-10-21