I need to join two pairs of tables. If there is an ID in Table1 that can also be found in Table3 I need to join the tables. If there is no matching ID from Table1 in Table3, I need to not join the tables.
Ex.
If there is at least one id in Table1 in Table3; do something that is effectively this:
SELECT * FROM Table1 AS t1 INNER JOIN Table2 AS t2 ON t1.ID = t2.ID LEFT JOIN Table3 AS t3 ON t1.ID = t3.ID LEFT JOIN Table4 AS t4 ON t3.ID = t4.ID If there are no IDs that match between Table1 and Table3; do something that is effectively this:
SELECT * FROM Table1 AS t1 INNER JOIN Table2 AS t2 ON t1.ID = t2.ID