I am using 2 tables, orders and order_items. I am trying to create a trigger that when I delete an order_id from orders table a row with the same order_id will be deleted in order_items table.
CREATE OR REPLACE TRIGGER orders_order_items
AFTER DELETE ON orders
BEGIN
DELETE FROM order_items WHERE order_items.order_id = orders.order_id;
END;
Could someone explain to me, why the above code does not work and how should it be written?