I believe it is correct the way it is... the display problem may be caused by another factor, configuration perhaps. If you reverse the sequence, the next post, would be code 115 and would be right after the "hello world" that was the first... recommend not perform this procedure without first checking what can be.
But if we look only at the question of reversing the numbering.
You first have to change all the numbers to an interval that has no conflicts. could do so:
update tabela set id = id + 1000;
Once done, you select by numbering the rows in descending id order and store them in a temporary table:
with temp as
(
select t.*, row_number() over (order by t.id desc) as i from tabela t order by t.id desc
)
Finally, you apply the new id in the record, as the select row number stored in the temporary table:
update tabela set id = (select x.i from temp x where x.id = tabela.id );
Mysql 8 was used as an example. row_number() is only available from this version.
For other versions, the following code can be used:
update tabela set id = id + 1000;
update tabela set id = (select x.i from (select t.*, @rownum := @rownum + 1 AS i from tabela t, (SELECT @rownum := 0) r order by t.id desc ) x where x.id = tabela.id );
I put in the Dbfiddle
The Bacco solution is clearly simpler and more functional for the case in question, but as I had already done the code to redo the numbering, I’ll leave it here too.
gives a sample of the data you have
– Rovann Linhalis
How do I do it?
– Sérgio Machado
puts in question some records you have, and what basic structure of the table, and how the final result should look
– Rovann Linhalis
see if you can understand now, doing a favor
– Sérgio Machado
what version of the bank ?
– Rovann Linhalis
5.7.19 this is the version of my mysql
– Sérgio Machado
solved your problem ? please check an answer
– Rovann Linhalis
nor tested, for two reasons, first that the customer saw no problem in the news to be in reverse order, and second because as I did in worpress and had already registered several prominent images, would generate problem
– Sérgio Machado
OK, either way both answers work, see sqlfiddle, so I would find it appropriate to mark the best (Bacco’s) as the answer to close the question
– Rovann Linhalis
I just did that, with that it might help other people who go through this problem, thanks man
– Sérgio Machado