我想知道如何或/和作品?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