Reputation: 109
I inherited some some bad SQL code (zero documentation and I'm missing the original requirements). In the where clause, it has the following:
A OR B AND C AND D OR E
From my knowledge of logical operands, my assumption is that SQL would compile this as:
A OR (B AND C AND D) OR E
Is that correct?
I have a feeling the intent was
(A OR B) AND C AND (D OR E)
and I will need to speak with those that requested this project in the first place, as I haven't seen the original requirements.
Upvotes: 3
Views: 1193
Reputation: 48865
You are correct. In the absence of parenthesis this should be interpreted as:
A OR (B AND C AND D) OR E
Upvotes: 2