IS
IS is an operator in SQL used in a WHERE clause to compare a column value to NULL, or to check if a column value matches a specific condition. The evaluation returns a Boolean value: TRUE if the condition is satisfied, otherwise FALSE.
Example
Output
Explanation
The SQL query above checks the table cities
for records where the population
field is NULL
. Two cities, Sacramento and Riverside have NULL
values in the population
field.
Example
Output
Explanation
In the given example, the IS
keyword is used in the WHERE
clause to filter the rows for which the Country field is NULL
. As a result, the output displays the EmployeeID
and FullName
of those Employees who do not have a country specified in the Employees table.
Example
Output
Explanation
In the example provided, a CASE
statement is used within a SELECT
statement to manipulate the output of the query. If the JOB_ID
is NULL
for employee ‘Williams’, the output would be ‘No Job’. If there is a JOB_ID
for ‘Williams’, the JOB_ID
will be displayed as the output. This IS
keyword is used to check whether the JOB_ID
column in the given row IS
NULL
.
Example
Output
Explanation
The example demonstrates the use of the IS operator in SQL, in particular SQLite. The IS operator is used to compare a value with null. In this case, it is used in the SELECT statement to retrieve records where the IsSold column is null. Since a default value was set for IsSold during table creation and none of the inserted records has null for IsSold, the resulting table is empty.