I have a table with the basic data, and a field is the management number. My goal is to first query the latest management number, generate a new management number according to the rule, and then insert it into the new data in the table.
I have a table with the basic data, and a field is the management number. My goal is to first query the latest management number, generate a new management number according to the rule, and then insert it into the new data in the table.
The requirements are as follows:
I have a table with the basic data, and a field is the management number. My goal is to first query the latest management number, generate a new management number according to the rules, and then insert the new data into the table because the query does not lock the table. so the two threads may find the same management number in the middle of the insert query?
The key is the following MYSQL statement,
Insert multiple records:
(Client_id, client_name, client_type)
Insert a single record:
(Client_id, client_name, client_type)
Therefore, you can check that the management number does not exist during insertion. If the insertion is unsuccessful, the latest management number is retrieved and re-calculated before insertion until the insertion is successful.
There are many such cases, such as tickets for trains and cinemas. Due to the large amount of concurrent processing, tickets with tickets are often found. However, this ticket has been sold when an order is placed, I don't know how these systems are handled.