- SQL Tutorial
- SQL Tutorial
- SQL Display Data
- SQL Update Records
- SQL Delete Record
- SQL Alter Table
- SQL Join Tables
- SQL Auto Increment
- SQL Drop Table/Database
- Computer Programming
- Learn Python
- Python Keywords
- Python Built-in Functions
- Python Examples
- Learn C++
- C++ Examples
- Learn C
- C Examples
- Learn Java
- Java Examples
- Learn C#
- Learn Objective-C
- Web Development
- Learn HTML
- Learn CSS
- Learn JavaScript
- JavaScript Examples
- Learn PHP
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.
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:
And here is the new snapshot of the table after executing the above SQL query, which deleted a row.
« Previous Topic Next Topic »