To put a SQL query in a TRANSACTION and COMMIT the transaction, you can use the following sample syntax:
START TRANSACTION;
UPDATE tablename
SET col1 = 'value1';
COMMIT;
To put a SQL query in a TRANSACTION and ROLLBACK the transaction, you can use the following sample syntax:
START TRANSACTION;
UPDATE tablename
SET col1 = 'value1';
ROLLBACK;
To put a SQL query in a TRANSACTION using savepoints to ROLLBACK the transaction, you can use the following sample syntax:
START TRANSACTION;
SAVEPOINT firstsavepoint;
INSERT INTO tablename
SELECT * FROM anothertablename
WHERE col1 = 'value1';
SAVEPOINT secondsavepoint;
DELETE FROM tablename
WHERE col1 = 'value2';
ROLLBACK TO firstsavepoint;