0
What command can I use to rearrange the ID of all items in a table?
The table name is produtos and the column is id.
Currently they are this way:
id: 1 - 3 - 7 - 8 - 9 - 11...
That is, they are not in correct sequence.
I need to leave them that way:
id: 1 - 2 - 3 - 4 - 5 - 6 - 7...
However it is important that it follows the correct sequence not to mix, e.g.:
1 = 1
3 = 2
7 = 3
8 = 4
9 = 5
11 = 6
The server is Mysql.
@Guillhermecostamilam
MySQLis a database server.– Roberto de Campos
@Wendler if I’m not mistaken, this will only be possible if you
truncarthe table, but when you perform an exclusion, theMySQLwill not reorder, even because theidcannot be changed since it can be referenced in other tables.– Roberto de Campos
@Robertodecampos... Yes, it would have to be through a
UPDATEfollowing some conditions, or is it not possible that way?– Wendler
@Sveen... Excellent friend, had not seen this question there, really solved my problem.
– Wendler
I had also researched it these days hahah
– Sveen