How can I join one table or other depending on a field value?
Short answer, you can't. Maybe you can do something like:

select ...
from t
left join t1
    on t.type = 1
    and t.x = t1.x
left join t2
    on t.type = 2
    and t.x = t1.x


to return something (must be same type) from either t1 or t2 you can use:

select coalesce(t1.y, t2.y) ...