I'm trying to make this query work:
SELECT
IFNULL(SUM(days), 0) AS days
FROM
`table_days`
WHERE task = 1
GROUP BY task
UNION
ALL
SELECT
IFNULL(SUM(total), 0) AS total
FROM
`table_total`
WHERE task = 1
GROUP BY task ;
I have two tables :
1. table_days
id task days
==========================
1 1 3.00
2 1 2.00
2. table_total
id task total
==========================
1 3 0.00
The query above partially works, the result is:
stdClass Object
(
[days] => 5.00
)
but I would like to get the result from second table even if there are no records found. Something like
stdClass Object
(
[days] => 5.00
[total] => 0.00
)