select t2.id, t2.date, coalesce(T.value, 0) value
from table2 t2
left join
(select t22.id, t22.date, t22.value
from table2 t22
where not exists (select null from table1 t1
where t22.date between t1.fromdate and t1.todate)
) T on t2.id = T.id and t2.date = T.date