NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL primary sort oddity

Hans Zaunere lists at zaunere.com
Sun Jan 30 18:20:46 EST 2005


> Right, so how is it that an auto_increment wouldn't sort by the id
> number?  Because if it's being sorted by the order it got entered,
> then it should still be in order.  At least that clears up a few
> things for me.

auto_increment isn't dependant on sorting.  It's an internal counter that is maintained in the table structure.  The order by which records appear when a SELECT is run without an ORDER BY is the order in which they lay in the on-disk datafile.  An auto_increment column, on the other hand, is just a counter.

> On a side note, anyway to have phpMyAdmin default sort by primary key?

Not that I know of, but you should always specify an ORDER BY when you want something sorted anyway, and not depend on some automatic behavior.


H





More information about the talk mailing list