MySQL IS Operator

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;
Example 1

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;    
MySQL IS Operator 3

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;
MySQL IS Operator 4

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;
IS Operator 5

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;
IS Example 6