What is MySQL DELETE command used for?

MySQLMySQLi Database

MySQL DELETE command is used to delete the row/s from a table. It is used with WHERE clause.

Syntax

DELETE From Table_name WHERE Condition;

Example

In the example below, we have deleted the rows from table ‘employee’ where id >=100.

mysql> select * from employee;
+------+--------+
| Id   | name   |
+------+--------+
| 100  | Ram    |
| 200  | Gaurav |
| 300  | MOHAN  |
+------+--------+
3 rows in set (0.00 sec)

mysql> delete from employee where id >=100;
Query OK, 3 rows affected (0.06 sec)

mysql> select * from employee;
Empty set (0.00 sec)
raja
Published on 19-Feb-2018 13:41:44
Advertisements