RE: [PHP-DB] mysql ORDER BY problems
| From: | Bastien Koert | Date: | Mon, 19 Jun 2006 02:17:28 +0000 |
| Subject: | RE: [PHP-DB] mysql ORDER BY problems | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42090@lists.php.net to get a copy of this message | ||
if you have these as strings, I would recommend a column data type conversion to int(or other numeric as the case may be)....failing that I would use the CAST command to convert the data to numerics
see here
http://dev.mysql.com/doc/refman/4.1/en/cast-functions.html
to use
select cast(fieldname as integer) from table where ... order by ...
bastien
From: "Rob W." <rob@fiberuplink.com> To: <php-db@lists.php.net> Subject: [PHP-DB] mysql ORDER BY problems Date: Sun, 18 Jun 2006 17:19:03 -0500 Ok, here's what i got in my mysql db. I got a table listed with numbers as follows 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 18 19 20 21 22 25 These numbers I can display fine. I'm using .. $query="SELECT * FROM db ORDER BY numbers ASC"; Right now it displays it as 1 10 11 12 ..... 2 22 23 25 .... 3 4 5 6 7 Is there a way with my mysql query so that I can list the numbers in correct order? Any help is appricated. - Rob