Search code examples
mysqlsqlselectoperator-precedence

Why is this "where" clause not limiting sql results


I'm trying to limit results in a table to records with dates that don't overlap my data. As you can see in the screenshot below I'm trying to add a clause to filter out records that are equal to the "end" column. See the final line in the query for that.

I can't figure out why results still show the record in the screenshot. Can someone help me out explaining that? It's probably a syntax thing?

SQL Where clause not filtering


Solution

  • You basically have:

    a OR b AND c AND d AND e AND f
    

    ... and you probably want:

    (a OR b) AND c AND d AND e AND f
    

    Reference: Operator Precedence