View Full Version : Ordering Result Alphabetically

04-15-2007, 10:16 PM
Ok, I am trying to get results from a database and show them alphabetically and am not sure how to do this. My guess is that it is in the mysql query string, maybe something like this:
$qry = mysql_query("SELECT * FROM `table` ORDER BY alphabetical ASC");Or something like that. Anyone know for sure?

04-15-2007, 10:21 PM
Well, which column in your database do you want to order alphabetically and does the column have words in it? If so, simply do this (let's say the column is called "names"):

$qry = mysql_query("SELECT * FROM `table` ORDER BY `names` ASC");

It will automatically place them in alpahbetical order.

Hope this helps.

04-15-2007, 10:31 PM
Thanks, I never even thought of it being automatic, you saved me a bunch of time :)

04-15-2007, 11:00 PM
It's not exactly automatic... it gets ordered by the numerical values of the characters.