Transactions and Commit Control in MySQL

Published July 26, 2025 By Sai Sree Ram Gundepudi

Example

START TRANSACTION;
UPDATE accounts SET balance = balance - 1000 WHERE id = 1;
UPDATE accounts SET balance = balance + 1000 WHERE id = 2;
COMMIT;

Use ROLLBACK if an error occurs to undo changes.

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article