I'm trying to figure out how to check if multiple rows exist in multiple tables in one statement.
Given the following tables:
table table_one ======== id 'a' 'b' 'c' table table_two ======== id 'aa' 'bb' 'cc'
SELECT 1 from table_one where id = 'a'
SELECT 1 from table_two where id = 'aa'
How can I combine them into one statement?
SELECT 1 FROM table_one WHERE id = 'a' UNION SELECT 1 FROM table_two WHERE id = 'aa'
but this just merges the results into one column so I cant tell if a particular table was missing a row.
What i'd like is a result row something this
table_one table_two table_three table_four ========= ========= =========== ========== 1 1 [null] 1