SQL DELETE STATEMENT
This statement is used to delete one/more/all rows from the table depending upon some conditions.
Syntax:
DELETE ALL DATA in table without deleting table structure, index, constraints.
DELETE * FROM "tableName";
OR
DELETE FROM "tableName";
DELETE DATA on the basis of some conditions OR by using where clause.
DELETE FROM "tableName"
WHERE columnName = value;
2. You must remember about foreign key constraints when deleting rows in parent table.
Parameters :
tableName : Name of the table in which we are going to insert data.
columnName, value : They will be used as criteria i.e columnName in the table containing specified value in it.
DELETE with one column : We will be using the same table which we have created in the CREATE TABLE and INSERT STATEMENT.
Using Select to see all the records before delete query runs.
SELECT * FROM `employee`;
DELETE FROM `employee` WHERE `id` = 3;
Above query will delete the row which has id 3.
Using Select to see all the records after delete query.
DELETE with some sql operators is below :
Using Select to see all the records before delete query.
SELECT * FROM `employee`;
DELEE FROM `employee` WHERE `salary` > 50000 AND `age` = 29 ;
Using Select to see all the records after delete query.