Coding task · SQL and MySQL course · Module 10: Transactions and advanced SQL

A loan in a transaction

A loan is two operations that must happen together: adding an entry to wypozyczenia and marking the book as unavailable. Wrap them in a transaction.

Task

Complete the transaction: start it with START TRANSACTION, then INSERT into the wypozyczenia table (ksiazka_id, czytelnik_id, data_wypozyczenia) with the values (1, 1, '2026-06-22'), then UPDATE the ksiazki table set dostepna = 0 for id = 1, and finally confirm the changes with COMMIT.