From cf8d117ec3f372e5ffeab4b0fc2c0ad7f26e8e2e Mon Sep 17 00:00:00 2001 From: alexey211204 Date: Sun, 5 Jul 2026 22:51:49 +0200 Subject: [PATCH] Solution1 --- task.sql | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..30d770e 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,19 @@ -- Use our database USE ShopDB; --- Some data should be created outside the transaction (here) +INSERT INTO Orders (CustomerID, `Date`) +VALUES (1, CURDATE()); + +SET @OrderID = LAST_INSERT_ID(); -- Start the transaction START TRANSACTION; --- And some data should be created inside the transaction +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (@OrderID, 1, 1); + +UPDATE Products +SET WarehouseAmount = WarehouseAmount - 1 +WHERE ID = 1; -COMMIT; \ No newline at end of file +COMMIT;