The MySQL IS Operator is useful for testing the given expression or value against a Boolean value True, False, and Unknown.
MySQL IS Operator Example
In this is operator example, we are checking the numeric and Null values using this operator.
SELECT 1 IS TRUE;
SELECT 0 IS TRUE, 0 IS FALSE;
SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;
IS Operator Practical Examples
The following is query returns 0 and 1 based on the result.
SELECT EmpID, `First Name`, `Last Name`, Qualification, Occupation, Income, Income IS TRUE, Income IS FALSE, Income IS UNKNOWN, Sales FROM new_Customers;
For better understanding, let me use the MySQL IS operator along with the TRUE keyword in the where clause. It returns the employees whose income is True (Positive integers).
SELECT EmpID, `First Name`, `Last Name`, Qualification, Occupation, Income, Sales, HireDate FROM customer WHERE Income IS TRUE;
This time, we used the IS with a false keyword. The following MySQL query returns the customers whose income is 0.
SELECT EmpID, `First Name`, `Last Name`, Qualification, Occupation, Income, Sales, HireDate FROM customer WHERE Income IS FALSE;
Here, we used the IS with an Unknown keyword. The below IS operator code selects the employees whose income is Null.
SELECT EmpID, `First Name`, `Last Name`, Qualification, Occupation, Income, Sales, HireDate FROM customer WHERE Income IS UNKNOWN;