The essence of the problem was that MyISAM tables have this ability and not for innoDB.
There is a table
messages
user_id INT
message_id INT
How to make so that when you insert into a table the values of the user_id, the value for message_id is generated
automatically?
Should be something like this
user_id | message_id |
---|
1 | 1 |
1 | 2 |
1 | 3 |
2 | 1 |
2 | 2 |
2 | 3 |
Made a trigger before insert which sets the value of the message_id as maximally id + 1,
everything works as it should, but after the insertion I do not know what message_id recorded the trigger.
The option of calculating the message_id and then insert (in two queries) is not suitable.