Deletes the chosen records from the table.
delete_statement_searched : DELETE FROM table_name [ WHERE search_condition ]
In FROM statement you should include the table which contains the records to be deleted. In WHERE statement you should include the selection criterion of the records to be deleted.
DELETE FROM tbl1 WHERE fldLong > 1000
If the WHERE statement is not defined all the table records will be deleted, the table becomes blank but it is not deleted from database.
DELETE FROM tbl1
DELETE with a Subquery.
Sometimes it is necessary to DELETE records using data from other tables. For this, you can use the selection conditions with the subquery.
Child queries in the WHERE statement can have several levels of embedding. They also can contain foreign links on the object table of the DELETE command. Foreign links are met very often as they implement the “uniting” of the subquery tables (table) and the object table of the DELETE command.
The sample of a scalar subquery:
DELETE FROM orders WHERE rep = ( SELECT empl_num FROM salesreps WHERE name = ‘ Sue Smith’) DELETE FROM salesreps WHERE ( .02* quota ) > ( SELECT SUM(amount) FROM orders WHERE rep = empl_num )
The sample of a multi-record subquery:
DELETE FROM customers WHERE cust_rep IN (SELECT empl_num FROM salesreps WHERE sales < ( .8* quota))