MySQL result order

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pettazz
Forum Newbie
Posts: 4
Joined: Mon Aug 06, 2007 7:53 pm

MySQL result order

Post by pettazz »

If I were to have a MySQL database with a bunch of random things in it, each having a sequential 'id' field, and a field called 'active' with either a 1 or a 0, and i ran this query on it

"SELECT * FROM someDb WHERE active = '0' ORDER BY id ASC LIMIT 1"

would I always be returning the lowest id where active = 0? or is it dependent on the arbitrary ordering of the items in the database?

basically what I'm asking is will ORDER BY id ASC only order a results list or will it use the whole database?
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Post by louie35 »

it will use the entire table to sort it out
pettazz
Forum Newbie
Posts: 4
Joined: Mon Aug 06, 2007 7:53 pm

Post by pettazz »

awesome, that saves me a lot of work.

thanks.
Post Reply