I need to check for a value in either table_one or table_two.
In table_one the value is stored as a foreign_key id referencing table_three and in table_two it is stored directly.
Pseudo code:
SELECT T1.*
FROM table_one T1
JOIN table_three T3 ON T3.id = T1.foreign_key
WHERE T3.field = 'value'
OR
SELECT T2.*
FROM table_two T2
WHERE T2.field = 'value';
I also need to know from WHICH table the value is actually selected.
Unfortunately the unnatural syntax of SQL makes this practically impossible to ‘figure out’ by one self.
1