![]() |
VOOZH | about |
The IS NULL operator in MySQL identifies records with missing values, helping ensure accurate queries and maintain data consistency.
Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE column_name IS NULL;It demonstrates how the IS NULL operator can be applied in different MySQL operations. First, we create a demo table on which the IS NULL operator will be applied:
This example shows how to retrieve records where a column contains NULL values. It helps identify rows with missing data.
Query:
SELECT order_id, customer_name, order_date
FROM Orders
WHERE shipping_date IS NULL;Output:
This example demonstrates how to count rows with NULL values. It is useful for analyzing incomplete data.
Query:
SELECT COUNT(*)
FROM Orders
WHERE shipping_date IS NULL;Output:
This example shows how to update records with NULL values. It is useful for replacing missing data with valid values.
Query:
UPDATE Orders
SET shipping_date = '2024-07-10'
WHERE shipping_date IS NULL
SELECT * FROM Orders;Output:
This example demonstrates how to remove records with NULL values. It helps clean up incomplete or unwanted data.
Query:
DELETE FROM Orders WHERE shipping_date IS NULL;
SELECT * FROM Orders;
Output: