I have a table with a primary key, auto_increment ID column. When I delete the row with the highest ID, for instance ID 100, I want to use that ID 100 for a new row only using a mysql trigger. How do I do that?
When I delete, for instance ID 1 AND the highest ID is 100, I don’t want to use ID 1 again.
I do the delete and insert statement with different PHP calls.
Finally I found the right solution for my problem. Thanks to all your suggestions en criticism. Instead of using a trigger, I now use a procedure (thanks for the idea @shubhansh).
This is the create statement for the procedure:
Now I can delete and alter one table in one PHP statement and it is save because the procedure locks the table.