Home > Database > Mysql Tutorial > How can we delete multiple rows from MySQL table?

How can we delete multiple rows from MySQL table?

PHPz
Release: 2023-09-12 09:17:12
forward
1239 people have browsed it

我们如何从 MySQL 表中删除多行?

We can delete multiple rows from a MySQL table using the DELETE statement and a WHERE clause that identifies these multiple rows.

Example

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

mysql> DELETE from names WHERE id > 2;
Query OK, 2 rows affected (0.04 sec)
Copy after login

The above query will delete multiple rows because the WHERE clause identifies two rows with id > 2 from table "names".

mysql> Select * from names;
+------+-----------+
| id   | name      |
+------+-----------+
| 1    | Rahul     |
| 2    | Gaurav    |
+------+-----------+
2 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How can we delete multiple rows from 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