krishna
krishna

Reputation: 923

type casting in mysql

i have passportno(varchar) in database.
i am entering values like this 001,002,003. and i want to display like sorting order.

now i wrote query like this "select * from passport_registration where status=1 ORDER BY passportno" then displaying output like this......077,088,099,100,1000,1001,1009,101,1010 i want to diplay sort order. how to do?

Upvotes: 1

Views: 2313

Answers (1)

simendsjo
simendsjo

Reputation: 4749

ORDER BY CAST(passportno AS UNSIGNED)

Upvotes: 7

Related Questions