One of those annoying problems that come along occasionally when you work alone and you get lost in your own head! I’m fully expecting the answer to be simple one:
I have a query like so:
SELECT * FROM table_a
LEFT JOIN table_b ON table_a.order_id = table_b.order_id
WHERE (table_a.column_a='string' OR table_b.column_b='string' OR table_b.column_c='string')
group by column_d
The query is returning all rows and seems to be disregarding the WHERE part of the query…except it isn’t. If I remove the OR parts it works as expected:
SELECT * FROM table_a
LEFT JOIN table_b ON table_a.order_id = table_b.order_id
WHERE (table_a.column_a='string')
group by column_d
Thoughts/obvious problems?
Update
My specific problem was that I was evaluating a string against an integer column, this meant the statement evaluated to unknown. Code is now as above but I only add that specific OR if the string is numeric
By observing your joining i had guess that some of the columns that you are comparing were nullable and where phase returns rows that results to true(NOTE THAT columns which were compared in where phase to null values were resulting to UNKNOWN. Does, not being returned. You can resolve this by adding a condition that would check if values were not Null)