2016-03-12 50 views
0

我知道它recomended使用括號以分開andor statements.but我想知道引擎如何MySQL的渲染報表不parenthesis.lets說,我們有這樣的說法:MySQL和&或優先

select * from users where A and B or C and D;

圓括號怎麼樣?

+0

** [Operator Precedence](https://dev.mysql.com/doc/refman/5.7/en/operator-precedence.html)**首先是AND,然後是OR。與代數'A * B + C * D'相同 – lad2025

+1

[Mysql or/and precedence?]可能重複(http://stackoverflow.com/questions/12345569/mysql-or-and-precedence) – SOFe

回答

3

這就像在數學表達式:

AND is like a PRODUCT 
OR is like a SUM 

左右,或之前被執行,除非通過括號中的數學不同的指示,像一次。