其中'foo'或'bar'AND'lol'或'rofl'MySQL [英] Where 'foo' OR 'bar' AND 'lol' OR 'rofl' MySQL

查看:96
本文介绍了其中'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.

推荐答案

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆