“foo”在哪里?或“酒吧”并且“哈哈”或“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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
AND
运算符的优先级高于 < code>OR 在 MySql 中,因此当前表达式的计算结果为:如果要强制计算顺序,请在表达式中添加括号:
The
AND
operator has higher precedence thanOR
in MySql, so your current expression evaluates as:Add parentheses to the expression if you want to force the evaluation order:
首先处理
AND
,然后处理OR
。所以,它将是:之后,它是从左到右的顺序。
AND
will be processed first, after thatOR
will be processed. So, it will be:After that, it is left to right order.
看一下文档 - 并且有更高的优先级,所以它会是这样的:
take a look at the documentation - AND has a higher precedence, so it would be like this:
将在 MS SQL Server 中为您提供以下结果:
因此,它似乎将结合 bar AND lol 并分别评估 foo 和 rofl,如下所示:
您可能想要做的是(技术上):
Will give you the following result in MS SQL Server:
So it seems it will combine bar AND lol and evals foo and rofl seperately like this:
What you probably want to do is (technically):