CREATE TRIGGER after_order_insert
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
UPDATE users
SET orders_count = orders_count + 1
WHERE id = NEW.user_id;
END;
NEW.* values or cancel the insertTriggers hide logic: an INSERT silently triggers a chain of changes in other tables. Hard to debug and invisible in application code. For most tasks, application-level event handlers are preferable.