INSERT is not the only statement that allows you to refer to another table. The
UPDATE statements do as well.
Imagine that an employee forgot to enter prices for some products that just arrived. However, some of these products have already been included in orders, even though they have not been priced. We can't give things away, so we need to delete these products from those orders.
For such a problem, we use the
DELETE FROM ... USING structure. Here's a statement that will do the trick:
DELETE FROM purchase
WHERE product.id = purchase.product_id
AND product.price IS NULL;
DELETE FROM, we name the table from which the rows will be deleted. Next is the
USING clause and a second table, the one which we will use to determine which rows to delete. We can do this by adding a
WHERE that joins these tables by the condition
product.id = purchase.product_id and specifies the condition
product.price IS NULL. You could use other conditions here as well.