Answer the question
In order to leave comments, you need to log in
How to guarantee to get a new record in a MySql query inside a transaction?
Good afternoon. Tell me how in a transaction in MySQL it is guaranteed to get a record that is created in an insert.
Example:
1) I start a transaction
2) I create a record after
3) I read I
get an empty list
4) I read it again in a second, there is a record
How to get the created record at the 3rd step INSERT INTO Customers ( code ) VALUES (155);
SELECT * FROM Customers WHERE code=155;
Answer the question
In order to leave comments, you need to log in
after the transaction, request LAST_INSERT_ID, and already use it for sampling
2) I create a record through INSERT INTO Customers ( code ) VALUES (155);
3) Reading SELECT * FROM Customers WHERE code=155;
I get an empty list
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question