Date in mysql select -
i have table a:
a.date | a.price 2013-10-01 | 5000 2013-10-02 | 5000 2013-10-03 | 5000 2013-10-04 | 5000 2013-10-05 | 5000
and table b:
b.date | b.price 2013-10-01 | 3500 2013-10-03 | 1600
in output receive following information:
2013-10-01 | 3500 2013-10-02 | 5000 2013-10-03 | 1600 2013-10-04 | 5000 2013-10-05 | 5000
how it, help!
you can use left join, , can try join table table b:
select a.date, coalesce(b.price, a.price) left join b on a.date=b.date
if join doesn't succeed, b.price null, otherwise have value. using coalesce() can first non null value.
please see fiddle here.
Comments
Post a Comment