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
Release: 2023-08-28 11:49:02
forward
728 people have browsed it

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template