Mysql how to convert varchar column to float or integer to order results
By admin on Jul 22, 2008 | In MySQL | 1 feedback »
I recently needed to order results of a varchar column in the same manner a float column would. I found this interesting way of doing it:
Select col1 from tbl1 order by 0+col1 asc;
col1 is a varchar column but if you use the digit zero and the plus operator mysql will order the results as if it were a float or integer (i.e. numeric as opposed to alphabetic).
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
1 trackback
This post has 517 feedbacks awaiting moderation...
Comments are not allowed from anonymous visitors.
| « Flash Embedded in HTML | SmartFtp free alternatives » |