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

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -