我想知道如何或/和作品?Mysql或/和优先级?
例如,如果我想在那里显示= 1
我可以做WHERE tablename.display = 1
,如果我想所有行显示= 1或2
我可以做的所有行WHERE tablename.display = 1 or tablename.display = 2
但是,如果我想获得的所有行什么地方显示= 1或2,其中任何内容,标记或标题中包含hello world
逻辑将如何发挥呢?
Select * from tablename
where display = 1 or display = 2 and content like "%hello world%" or tags like "%hello world%" or title = "%hello world%"
会是我的猜测。但是我可以用几种方式阅读。
它读出为:
(display = 1 or display = 2) and (content like "%hello world%" or tags like "%hello world%" or title = "%hello world%")
或
((display = 1 or display = 2) and (content like "%hello world%")) or (tags like "%hello world%" or title = "%hello world%")
等
http://dev.mysql.com/doc/refman/5.5/en/operator-precedence.html – zerkms
这些东西是在您早期的C/C++课程中教授的。 –
然后,我想我应该注册一个完整的C/C++课程,以了解运算符的优先级:/ – Hailwood