我有以下查询,AND状态= 1被忽略,我得到所有状态而不是只有等于1.我的错误在哪里?
$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
";
答案 0 :(得分:0)
您需要使用括号
定义AND的开始和结束$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
";