Hi,
I have a MySQL varchar column which I wish to display. Most of the entries are numbers eg 1, 2, 3 etc etc. But some are numbers and letters eg 34A, 34B, 35A.
When I display the column I am able to sort by number using the "order by column_name+0" command, as in:
$result = mysql_query("SELECT id, house, pen, date_format(start,'%M %D, %Y') as start, date_format(end,'%M %D, %Y') as end, details FROM animalhouse WHERE house='old' ORDER BY pen+0") or die (mysql_error());
However, it doesn't sort the letters properly, so I get 34B, 34A, 34C etc etc.
Is there a simple way for me to make it sort by number first and then by letter?
Not in your query. Try resorting it using a natural sort in PHP. The A, B, and C should be in another column, anyhow.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php