DELETE query in MySQL

MySQL DELETE:
The MySQL DELETE statement is used to eliminate data records from a table.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
DELETE FROM table_name
WHERE conditions;
DELETE FROM table_name WHERE conditions;
DELETE FROM table_name  
WHERE conditions;

 

Example: Items table before deletion:

ID NAME QUANTITY
1 Electronics 30
2 Sports 45
3 Fashion 100
4 Grocery 90
5 Toys 50
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
DELETE FROM items
WHERE id = 3;
DELETE FROM items WHERE id = 3;
DELETE FROM items
WHERE id = 3;

Explanation:
The ‘items’ is an existing table, from which we delete the row where the id is 3.

Items table after deletion:

ID NAME QUANTITY
1 Electronics 30
2 Sports 45
4 Grocery 90
5 Toys 50