# DELETE FROM: delete rows
Just as you can SELECT
to find rows in a table, you can DELETE
[1] rows!
It's simple, yet dangerous:
DELETE FROM users WHERE surname = 'Smith';
Here we don't have to specify which columns we want to delete, because that wouldn't make much sense. Given this SQL query, the database would delete all rows that have a column surname
with a value of 'Smith'
. Remember that might be more than one row!
DANGER
Careful with this:
DELETE FROM users;
As that will delete all rows from your table. It can be useful, but if it's not what you want, don't do it!
As we learned in the last chapter, you can use WHERE
and multiple conditionals as you wish to filter the result. Only instead of getting the result back, when you execute a DELETE FROM
query you'll be deleting rows from the table.