What if we only want to delete a specific number of rows?


#1

Question

In the context of this exercise, what if we only want to delete a specific number of rows?

Answer

To delete only a specific number of rows, you can utilize the LIMIT statement. The value provided for LIMIT will be how many rows to affect.

For example, this statement will only delete the first 5 rows that match the condition,

DELETE FROM table
WHERE condition
LIMIT 5;