Uses for DELETE

At this point, you should have a good understanding of how to delete one or more rows in a table—either all the rows or a selection of rows determined by using a WHERE clause. The best way to give you an idea of the wide range of uses for the DELETE statement is to list some problems you can solve with this statement and then present a set of examples in the Sample Statements section. Here’s just a small list of the types of problems that you can solve with DELETE.

“Delete products that have never been ordered.”

“Delete all entertainers who have never been hired.”

“Delete bowlers who have not bowled any games.”

“Delete all students who are not registered for any class.”

“Delete any categories that have no products.”

“Delete ...

Get SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.