Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Inserting and updating NULLs
8. IS NULL in DELETE
Conditions in UPDATE and DELETE
Using values from another column
Inserting data from a query
Summary

Instruction

Great! You know how to use IS NULL in an UPDATE statement. Now it's time to get familiar with IS NULL in another statement: DELETE. The command below explains why it is sometimes worth using IS NULL with DELETE:

DELETE FROM student
WHERE last_name IS NULL;

This command removes all students without a last name from the database. A last name is a very important way to identify a student, and a record without it is not useful. Here, we use IS NULL to check if the last_name column has a NULL in it. The query leaves only student records with existing last names in the database.

Exercise

A group of students weren't scored on an oral exam, so the exam was canceled. The results from this exam have to be removed. Write a query to remove these records.