MYSQL在我的查询中忽略AND子句[重复]

This question already has an answer here:

I have the following query, the AND state = 1 is being ignored, i get all the states instead of only what is equal to 1. Where is my mistake here?

$query = "
                SELECT state, id, variable, name, {$columns->specific}, {$columns->allExcept}, {$columns->specificExclude}, {$columns->relationAllExcept}, repeatable

                FROM #__epc_fieldsgroups
                WHERE FIND_IN_SET({$relationRecordId}, {$columns->specific})

                OR {$columns->allExcept} != 0
                AND FIND_IN_SET({$relationRecordId}, {$columns->allExcept}) = 0

                AND state = 1
                ORDER BY ordering
             ";
</div>

you need to define start and end of AND using parentheses

$query = "
                SELECT state, id, variable, name, {$columns->specific}, {$columns->allExcept}, {$columns->specificExclude}, {$columns->relationAllExcept}, repeatable

                FROM #__epc_fieldsgroups
                WHERE FIND_IN_SET({$relationRecordId}, {$columns->specific})

                OR {$columns->allExcept} != 0
                AND {FIND_IN_SET({$relationRecordId}, {$columns->allExcept}) = 0}

                AND {state = 1}
                ORDER BY ordering
             ";