Where operators can be used

Comparison operators and functions can appear as conditions, such as part of the WHERE clause or join ON conditions. In addition, they can appear in the SELECT list or other locations where expressions can appear. In the latter case, they return 0 if false, 1 if true, and NULL if an input is NULL. For example:

SELECT t, t LIKE 'r%', t != 'red' FROM s WHERE t = 'red';
+------+-------------+------------+
| t    | t LIKE 'r%' | t != 'red' |
+------+-------------+------------+
| red  |           1 |          0 |
+------+-------------+------------+

Last modified: April 24, 2021

Was this article helpful?