From 7a09199584bfead2eec159de250bf0da2962d129 Mon Sep 17 00:00:00 2001 From: maxmlv Date: Mon, 22 Jun 2026 18:30:33 +0300 Subject: [PATCH] implement an order transaction --- task.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/task.sql b/task.sql index 8adf22b..9b7af16 100644 --- a/task.sql +++ b/task.sql @@ -7,5 +7,8 @@ USE ShopDB; START TRANSACTION; -- And some data should be created inside the transaction +INSERT INTO Orders (CustomerID, Date) VALUES(1, CURDATE()); +INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES(LAST_INSERT_ID(), 1, 1); +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; COMMIT; \ No newline at end of file