'Order by' question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

Thanks
Justin

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux