Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reindex mysql table

Tags:

mysql

I have a table with many rows but they are out of order. Im using the field "id" as the primary key. I also have a "date" field which is a datetime field.

How could i reindex the table so that the entries are id'd in chronological order according to the date field

like image 622
mrpatg Avatar asked Jan 18 '10 21:01

mrpatg


1 Answers

the way i would do it is to create a new table with auto increment index and just select all your old table into it ordering by date. you can then remove your old table.

like image 106
Josh Avatar answered Oct 16 '22 01:10

Josh