From 50757a283259b0ac3e3877fc121d32d6e6c38c55 Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Thu, 7 Mar 2024 22:37:28 +0100 Subject: [PATCH] Account for null when no more cart items are present --- shop.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shop.sql b/shop.sql index 30ea0cf..b085cde 100644 --- a/shop.sql +++ b/shop.sql @@ -121,10 +121,11 @@ after delete on cart_item for each row begin update cart - set price_total = ( - select sum(price_subtotal) + set price_total = ifnull( + (select sum(price_subtotal) from cart_item - where cart_id = old.cart_id + where cart_id = old.cart_id), + 0.00 ) where id = old.cart_id; end;