
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Why does MySQL evaluate “TRUE or TRUE and FALSE” to true?
MySQL evaluates “TRUE or TRUE and FALSE” to true because AND has the highest priority than OR i.e. AND is evaluated before OR.
The MySQL evaluates the above statement like this. The AND operator gets evaluated first −
(TRUE or (TRUE AND FALSE))
The statement (TRUE AND FALSE) gives the result FALSE. Then the second statement evaluates like this −
(TRUE or FALSE)
The above statement gives the result TRUE.
Let us implement one by one −
mysql> select (TRUE AND FALSE); +------------------+ | (TRUE AND FALSE) | +------------------+ | 0 | +------------------+ 1 row in set (0.00 sec)
Now we can put the above result in place of AND condition −
mysql> select (TRUE or FALSE); +-----------------+ | (TRUE or FALSE) | +-----------------+ | 1 | +-----------------+ 1 row in set (0.00 sec)
Now check the whole condition once again −
mysql> select (TRUE or TRUE and FALSE);
This will produce the following output −
+--------------------------+ | (TRUE or TRUE and FALSE) | +--------------------------+ | 1 | +--------------------------+ 1 row in set (0.00 sec)
- Related Articles
- If ([] == false) is true, why does ([] || true) result in []? - JavaScript
- State True or False-
- Light does not need any medium to travel.Is it true or false?
- Geolocation HTML5 enableHighAccuracy True, False or What?
- Indicate the following, is true or false.
- Yeast is a fungus. True or False.
- Cotton and jute are natural fibres. (True or False)
- Electromagnets are used in motors. True or False?
- Every change has a cause. (True or false)
- Jute is produced in Jammu and Kashmir. (true or false)
- State true or false: Motion and rest are relative terms.""
- Display TRUE FALSE records as 0 1 in MySQL
- Angora goat is found in Tibet.(True or False )
- State true or false: Time is a vector quantity"."
- Acceleration is a scalar quantity." State true or false."

Advertisements