SQL IS NULL

IS NULL operator is used to check whether a column contains NULL values.

What is NULL?
      • NULL means no value / missing value / unknown value.
      • It is not equal to 0 or an empty string.

Important Rule:
      • You cannot use symbol = or != with NULL.

Syntax

SELECT column1, column2
FROM table_name
WHERE column_name IS NULL;

Example: Find Orders Not Yet Delivered

SELECT OrderID, DeliveryDate
FROM Orders
WHERE DeliveryDate IS NULL;

-- This query returns orders where DeliveryDate is missing.

Syntax(IS NOT NULL): To find records that have values, use IS NOT NULL.

SELECT column1
FROM table_name
WHERE column_name IS NOT NULL;

Example

SELECT OrderID, DeliveryDate
FROM Orders
WHERE DeliveryDate IS NOT NULL;

Example: Find customers whose Email is missing:

SELECT CustomerID, Email
FROM Customers
WHERE Email IS NULL;


Quick Interview Definition:
IS NULL is a SQL operator used to check whether a column contains NULL (missing) values in a table.


Topics