select value1 as value from T1 where id=10;
if id does not exist in T1 – execute another query:
select value2 as value from T2 where id=10;
So, I want to join these queries and return a single value (value1 or value2). Is it possible?
SOLUTION:
My solution:
select ifnull(value1, value2) as value from T1 left join T2 using(id) where id=10;
TRY (tested)
this will always check first the table t1 for id=10, if there is no value then see table t2 for the same id
Quoted FROM