- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we delete multiple rows from a MySQL table?
We can use DELETE statement along with a WHERE clause, which identifies those multiple rows, to delete multiple rows from MySQL table.
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)
The query above will delete multiple rows because WHERE clause identify two rows having id > 2 from table ‘names’.
mysql> Select * from names; +------+-----------+ | id | name | +------+-----------+ | 1 | Rahul | | 2 | Gaurav | +------+-----------+ 2 rows in set (0.00 sec)
- How can we delete all rows from a MySQL table?
- How can we delete a single row from a MySQL table?
- Delete multiple entries from a MySQL table
- How can we remove a column from MySQL table?
- How can we delete a MySQL stored function from the database?
- How can you delete a table from a database in MySQL Python?
- Delete more than one rows from a table using id in MySQL?
- How can we drop UNIQUE constraint from a MySQL table?
- Delete only some rows from a table based on a condition in MySQL
- Delete only specific rows in a table with MySQL
- How can I delete MySQL temporary table?
- How can you delete a record from a table using MySQL in Python?
- Can we remove a primary key from MySQL table?
- How can we delete an existing MySQL table by using PHP script?
- How can we set PRIMARY KEY on multiple columns of a MySQL table?