NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL primary sort oddity

Hans Zaunere lists at zaunere.com
Sun Jan 30 18:05:26 EST 2005


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






More information about the talk mailing list