NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL primary sort oddity

Brian O'Connor gatzby3jr at gmail.com
Sun Jan 30 18:12:59 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.

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


On Sun, 30 Jan 2005 18:05:26 -0500, Hans Zaunere <lists at zaunere.com> wrote:
> 
> Hi Brian,
> 
> > I have a users table on my website that primary field 'id', which is
> > auto_incremental.  This usually never happens, and really doesn't
> > affect anything in anyway, but it's bugging me to why it's happening.
> > When I'm looking at it through phpMyAdmin, with the query "SELECT *
> > FROM users" the output is:
> >
> > 1 - 13
> > then 15
> > 14
> > 16 and on
> >
> > I'm not an expert on MySQL to any degree, but I though if no ORDER was
> > input, it auto sorted by the primary key (if none provided, I figured
> > index was then taken, then just the order it was input).
> 
> If no ORDER BY is used, then there is no sorting, primary key or not.  I don't know of any database that's any different.  It'll be in the order in which the data lies in the file, which should always be assumed as random.
> 
> ---
> Hans Zaunere
> President, Founder
> New York PHP
> http://www.nyphp.org
> 
> Hans Zaunere, Sales Engineer
> MySQL, Inc.  www.mysql.com
> 
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
> 


-- 
Brian O'Connor



More information about the talk mailing list