Click to See Complete Forum and Search --> : Mysql - How to order the rows in a table with auto increment.


Mega69
01-20-2008, 04:41 AM
Hello,
I have a mysql table similar to this:
id dato1 dato2
1 'a' 'b'
2 'c' 'd'
3 'e' 'f'
where 'id' is a field with auto increment.

--Question 1--
If I delete a row, for example the second, I get something like this:
id dato1 dato2
1 'a' 'b'
3 'e' 'f'
Does a way to "recalculate" all the ids exist? I just want to get something like this:
id dato1 dato2
1 'a' 'b'
2 'e' 'f'

--Question 2--
How can I invert two rows without changing the ids?
id dato1 dato2
1 'a' 'b'
2 'e' 'f'
3 'c' 'd'


Besides I'd like to know if it's possible to do these things in a simpler way by using phpmyadmin.

chazzy
01-21-2008, 09:12 AM
In general, I don't think you actually want to reassign ID's. The ID is the unique discriminator of an entry - why should it ever change?