Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql alter table order by not working

Tags:

php

mysql

laravel

I have searched over net a lot. What I could understand is that this thing has been faced by many people before me and it has also been filed as mysql bugs. But I couldn't find any solution to this. The problem is just that I can't get this command working-

alter table areas order by area_name;

I get this warning-

ORDER BY ignored as there is a user-defined clustered index in the table 'areas'

I just want to sort the table on the basis of 'area_name', that is, names of areas. Just to add, I am trying to do this in the database of my laravel app.

like image 845
halkujabra Avatar asked Feb 03 '26 15:02

halkujabra


1 Answers

If the db engine is InnoDB, then you can't do this.

From the doc:

ORDER BY does not make sense for InnoDB tables because InnoDB always orders table rows according to the clustered index.

like image 134
xdazz Avatar answered Feb 05 '26 06:02

xdazz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!