Answer the question
In order to leave comments, you need to log in
Restoring numbering in the database, the field is not auto-increment?
There is a table. 8 entries are entered into the table with each addition (1 pack = 8 entries). These eight records have a field responsible for the position, respectively, it is the same for each pack.
For the first eight it will be 1, for the second eight it will be 2, and so on. (I would kill for such an organization). After the pack is removed, the sequence is broken.
For example, if you deleted the second pack, then there are 8 records left with the value 1 and 8 with the value 3.
The question is: how to return the sequence to each pack after each deletion?
MySQL, I didn't write it, they asked me to fix it. I'm shocked.
Answer the question
In order to leave comments, you need to log in
Eh ... well then:
Select @i:=0; Update TBL Set index = @i := @i +1, index = floor(index/8);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question