sort varchr field

I've ID Field varchar. when i use order by ID it sorted as
1
11
2
22
3
I'd like to sort this field as integer value ( in some reports)
1
2
3
11
22
khaled salemSoftware DeveloperAsked:
Who is Participating?
 
mrh14852Commented:
Sorry should have been more specific CAST(ID AS SIGNED) AS ID
0
 
mrh14852Commented:
Use the CAST() function.

SELECT CAST(ID) AS ID
ORDER BY ID

http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast
0
 
khaled salemSoftware DeveloperAuthor Commented:
can you explain in more details
0
 
khaled salemSoftware DeveloperAuthor Commented:
exactly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.