Emam Hossen
Emam Hossen

Reputation: 41

SQL Transaction statement not working in Xampp

I was trying to commit a transaction in Xampp. The SQL is as follows:

BEGIN TRANSACTION;

UPDATE accounts
   SET balance = balance - 1000
 WHERE account_no = 100;

UPDATE accounts
   SET balance = balance + 1000
 WHERE account_no = 200;

INSERT INTO account_changes(account_no,flag,amount,changed_at) 
values(100,'-',1000,datetime('now'));

INSERT INTO account_changes(account_no,flag,amount,changed_at) 
values(200,'+',1000,datetime('now'));

COMMIT;

The error is at line 1 as- BEGIN TRANSACTION [Unrecognized Keyword] [Transaction_Error]1

Upvotes: 0

Views: 1749

Answers (1)

Shadow
Shadow

Reputation: 34294

There is no such statement in MySQL as begin transaction. You can choose between start transaction, begin, or begin work to start a transaction. See MySQL documentation on start transaction for further details.

Upvotes: 1

Related Questions