I have a problem with a sql-statement.
My DB is MySQL 5.1.
I have 2 tables:
day_table
date(pk) note ...
------- ----- ---
2012-03-29 foo ...
2012-03-30 bar ...
2012-03-31 foobar ...
other_table
id fk_date key value
-- ------- --- -----
1 2012-03-29 foo 5
2 2012-03-30 bar 9
3 2012-03-30 foo 4
4 2012-03-31 bar 6
5 2012-03-31 foo 1
So I need a query something like this:
SELECT o.value, d.date FROM other_table o join day_table d on (...) where key = "bar" group by d.date;
And I need a result like this:
result_table
date(pk) value
------- -----
2012-03-29 0 (or null) <---- THIS IS IMPORTANT!!!
2012-03-30 9
2012-03-31 6
I know the problem is the join, but I need to get each date in day_table.
Is this possible with (My)SQL?
Best Regards
use left join instead of inner join: