本文介绍了其中'foo'或'bar'AND'lol'或'rofl'MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以什么顺序进行评估.我的意图是,如果找到foo或bar,它也会搜索lol和rofl.
这完全在树林里吗?如果是这样,人们将如何评估这样的表达式.
In what order would this be evaluated. My intension is that if it finds either foo or bar, it would also search for lol and rofl.
Is this totally in the woods? And if so, how would one evaluate an expression like that.
推荐答案
在MySql中,AND
运算符的优先级高于OR
,因此您当前的表达式的计算结果为:
The AND
operator has higher precedence than OR
in MySql, so your current expression evaluates as:
WHERE 'foo' OR ('bar' AND 'lol') OR 'rofl'
如果要强制求值顺序,请在表达式中添加括号:
Add parentheses to the expression if you want to force the evaluation order:
WHERE ('foo' OR 'bar') AND ('lol' OR 'rofl')
这篇关于其中'foo'或'bar'AND'lol'或'rofl'MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!