Delete a Single Row from a MySQL Table



We can use DELETE statement along with a WHERE clause, which identifies that particular row, to delete a row from 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 query above will delete a single row having id = 4 from table ‘names’.

mysql> Select * from names;
+------+-----------+
| id   | name      |
+------+-----------+
| 1    | Rahul     |
| 2    | Gaurav    |
| 3    | Raman     |
| 5    | Ram       |
+------+-----------+
4 rows in set (0.00 sec)
Updated on: 2020-06-20T07:31:48+05:30

363 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements