Home >Database >Mysql Tutorial >How can we delete a single row of data from a MySQL table?

How can we delete a single row of data from a MySQL table?

WBOY
WBOYforward
2023-08-28 11:49:02732browse

How can we delete a single row of data from a MySQL table?

We can use the DELETE statement and WHERE clause to delete specific rows in the MySQL table.

Example

mysql> Select * from names;
+------+-----------+
| id   | name      |
+------+-----------+
| 1    | Rahul     |
| 2    | Gaurav    |
| 3    | Raman     |
| 4    | Aarav     |
| 5    | Ram       |
+------+-----------+
5 rows in set (0.00 sec)

mysql> DELETE from names where id = 4;
Query OK, 1 row affected (0.07 sec)

The above query will delete a row with id = 4 from the table ‘names’.

mysql> Select * from names;
+------+-----------+
| id   | name      |
+------+-----------+
| 1    | Rahul     |
| 2    | Gaurav    |
| 3    | Raman     |
| 5    | Ram       |
+------+-----------+
4 rows in set (0.00 sec)

The above is the detailed content of How can we delete a single row of data from a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete