Need is such, there are a few data, a, b, c, a need to put the data inserted into the table 1, and then take to automatically generate the id of the table 1, together with the b is inserted into a table 2; Then id is inserted into a table with c 3, I points three statements written, there is a problem, sometimes the first mysql performed, but not the second implementation success, thus leading to the lack of data,
Want to, so if we can put the three statements to synthesize 1, and then submit together, success is successful, the failure is together
If you can, how do you write this statement?
CodePudding user response:
1, use the stored procedure that is punctuated with transactions, these three operations in a transaction, success is success, failure is failure, 2, use the last_insert_id get inserted into the generated on the id in the table, as the data into a table,