DELETE FROM statement deletes one or more rows from a table. You can use the statement when you want to delete existing records. The statement below deletes all records in the
celeb table with no
DELETE FROM celebs WHERE twitter_handle IS NULL;
DELETE FROMis a clause that lets you delete rows from a table.
celebsis the name of the table we want to delete rows from.
WHEREis a clause that lets you select which rows you want to delete. Here we want to delete all of the rows where the twitter_handle column
IS NULLis a condition in SQL that returns true when the value is
NULLand false otherwise.
Delete all of the rows that have a
NULL value in the twitter handle column. In the code editor, type the following:
DELETE FROM celebs WHERE twitter_handle IS NULL; SELECT * FROM celebs;
How many rows exist in the
celebs table now?