I have a query with a joined subquery. If the subquery returns null, I want it to be ignored and I want to the rest of the query to work normally.
Currently I have something like:
SELECT a, b, c, d
FROM tblOne
JOIN tblTwo ON tblOne.a = tblTwo.a --this works fine
JOIN
(SELECT a
FROM tblThree) ON tblThree.a = tblOne.a
The problem is that if tblThree.a is null, the entire query returns null. So, I only want to use the subquery if tblThree.a is not null.
Can I do something with CASE or COALESCE, or some other way? Please give code examples.
left outer jointo that subquery, if it didnt return anything it would be ignored