How To Sort Text as a Number in MySQL

select theField from theTable order by theField+0;
~OR~
select theField from theTable order by CAST(theField AS UNSIGNED);
select theField from theTable order by theField+0;
~OR~
select theField from theTable order by CAST(theField AS UNSIGNED);
Categories: How-To's, Technology Tags: 0, Add, Cast, howto, Number, sort, String, text(), tips, Zero
Copyright © 2005-2025 Eric Michael Stone | Random Thoughts, Whims and Fancies…. Powered by WordPress
Leave Your Comment
All fields marked with "*" are required.