Delete a Row from a Table in SQL

This post is created to describe how to delete a row or a record from a table in SQL. So to achieve this task, we have the DELETE FROM statement. Here is its general form.

DELETE FROM tableName WHERE condition;

For example:

DELETE FROM customer WHERE id=3;

The above SQL query will delete a row whose "id" value is equal to 3 from the table named "customer."

Don't forget to include the WHERE clause to delete a specific row or number of rows from a table, until and unless you need to delete all the records or rows. That is, to delete all the rows of a table named "customer." Here is the SQL query you need to write.

DELETE FROM customer;

Example

Now let me create an example of deleting a row from a table in SQL. But before taking an example, let me show you the table data with which I'm going to work.

sql delete row from table

Now, through the following SQL query, a row whose id value is 7 will be deleted from the table.

DELETE FROM customer WHERE id=7;

After executing the above SQL query, here is the output you will see:

sql delete record from table

And here is the new snapshot of the table after executing the above SQL query, which deleted a row.

sql drop row from table

SQL Online Test


« Previous Topic Next Topic »

Follow/Like Us on Facebook




Subscribe Us on YouTube