Deviopath › PostgreSQL

Clear Out Cancelled Items

Medium · Delete

DELETE FROM a USING b WHERE ... deletes rows from a while looking at another table b, like a join. A subquery (WHERE id IN (SELECT ...)) works too.

Delete every row of order_items that belongs to an order with status cancelled. Keep the orders themselves. The check lists the remaining order_items rows.

Next: Apply Scheduled Price Changes