MySQL IS Operator

The MySQL IS Operator is useful to test the given expression or value against a Boolean value True, False, and Unknown.

MySQL IS Operator Example

In this MySQL 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;
MySQL IS 1

MySQL IS Practical Examples

The following is operator 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 `MySQL Tutorial`.new_Customers;    
MySQL IS Operator 3

For better understanding, let me use the 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 `MySQL Tutorial`.customer
WHERE Income IS TRUE;
MySQL IS Operator 4

This time, we used the IS operator 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 `MySQL Tutorial`.customer
WHERE Income IS FALSE;
MySQL IS Operator 5

Here, we used the IS operator with an Unknown keyword. The below MySQL IS code selects the employees whose income is Null.

SELECT EmpID, 
`First Name`,
      `Last Name`,
      Qualification,
      Occupation,
      Income,
      Sales,
      HireDate
FROM `MySQL Tutorial`.customer
WHERE Income IS UNKNOWN;
MySQL IS Operator 6