Home > database >  MYSQL connection table data into question
MYSQL connection table data into question

Time:10-05

I now have a set of data needs to be written in two tables inside, there is a connection between the two tables, hope at the time of writing data, either two tables at the same time to succeed, or two tables to fail at the same time. I now is to use to judge a table after the success of the writing, one table to another, sometimes occur as a result, the first written to success, the second table write failed, strives for the great god give a guide,

CodePudding user response:

In a transaction to go
Start the transaction;
Insert a t1;
Insert t2;
Commit;

CodePudding user response:

http://wwty.iteye.com/blog/699137

CodePudding user response:

Success and failure with the transaction can be achieved, success is rolled back will not insert data,
  • Related