diff --git a/task.sql b/task.sql index 8adf22b..5e956c6 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,6 @@ --- Use our database -USE ShopDB; - --- Some data should be created outside the transaction (here) - --- Start the transaction +USE ShopDB; +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); START TRANSACTION; - --- And some data should be created inside the transaction - +INSERT INTO OrderItems (ProductID, Count, OrderID) VALUES (1, 1, LAST_INSERT_ID()); +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; COMMIT; \ No newline at end of file