有没有更好的方法来编写mysql查询的以下’where’部分:
WHERE t.status IS NOT 'resolved'
AND t.status IS NOT 'closed'
AND t.status IS NOT 'deleted'
他们可以合并成一个单独的声明吗?
最佳答案
WHERE t.status NOT IN ('resolved','closed','deleted')
布尔代数说这两个表达式是等价的:
NOT A AND NOT B AND NOT C
NOT (A OR B OR C)