Transactions and Commit Control in MySQL

Published September 09, 2026 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