How can we 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: 20-Jun-2020

243 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements