IntermediateINSERT, UPDATE, DELETE
DELETE with JOIN condition
The query
SQL
DELETE FROM order_items oi
USING orders o
WHERE oi.order_id = o.order_id
AND o.status = 'cancelled'
AND o.order_date < NOW() - INTERVAL '1 year';Note
“PostgreSQL DELETE USING syntax for join conditions. Equivalent of DELETE with JOIN.