Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does mysql evaluate (TRUE or TRUE and FALSE) to true?

Tags:

sql

mysql

If you type

SELECT (true or true and false) 

in mysql it will return 1 which is true. Why is that so? What's the order of evaluation in boolean expressions?

like image 583
Sequoia Avatar asked Oct 17 '25 03:10

Sequoia


1 Answers

According to the MySQL documentation on operator precedence, AND is evaluated before OR.
That means your expression (true OR true AND false) is evaluated as (true OR (true AND false)).

like image 179
Mr. Llama Avatar answered Oct 19 '25 19:10

Mr. Llama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!