0
I have a PHP + Mysql application, and I need to create a next numbering of a record according to another column. Therefore, AUTO_INCREMENT does not solve, because it always adds one more, indifferent to PRIMARY KEY. And my tables are Innodb. What would be the best practice? Because if I perform a SELECT MAX() to get the next number, you run the risk of another session performing at the same time and duplicate or generate error.
Thank you.
You can explain this part better: "and I need to create a next numbering of a record according to another column", more details?
– Leonardo Barros
I’ve had problems with record duplication as well, and I didn’t want to use auto_increment because I made some jumps in the number range. What I did was a SELECT MAX() function and incremented it, but I did it all at the time of entering the record, and in no time before. That already solved my problem.
– Bruno