Weird issue with the order of clauses seeming to matter
OK, just to follow up my correct (yay!) comment answer - in my experience almost everything along the lines of "weird issue" involving data selection, involves a rogue, unparenthesised "OR" somewhere in the where clause. It's always the first place I'd look.

Typically you write some code along the lines of:

WHERE a
AND b OR c
AND d


and then when you look at the code your mind kind of fills in the parenthesis where you think it ought to be. Whereas order or precedence rules actually perform it thus:

WHERE (a AND b) OR (c AND d)


A good trick to use when coding, which I tend to do automatically now, is as soon as you use an "OR" anywhere in your code, then add some parenthesis to make it totally clear.

Even if your where clause is simply:

WHERE a OR b


Then explicitly change it to

WHERE ( a OR b )


since, you're future-proofing against someone adding to the code later and accidentally writing something like:

WHERE a OR b
AND c