Basically, I have table a, which has a type and type_id and want to join on either two different tables where there is a hit.
So basically, if table b has a match, return the record or if table c has a match, return that record (essentially two inner joins with an OR); just one of them has to match. The below query seems to work... however I feel like this is a very naive solution that will actually result in me running into some issues.
SELECT a.* FROM a LEFT JOIN b ON a.type_id = b.id AND b.user_id = 123 AND a.type = 'dog' LEFT JOIN c ON a.type_id = c.type_id AND c.user_id = 123 AND a.type = 'cat' WHERE b.id IS NOT NULL OR c.type_id IS NOT NULL; Basically, I want all the records where the user exists in either table.