mysql - Sorting a varchar column as a numeric one using collate -


i have mysql table has varchar column. column contains numbers , want able sort numerically, i.e. 100, 101, 1001. sorts them 100, 1001, 101 etc. heard alter table add collate attribute sorted numerically. when type "show collation" don't see collation type seems meant treating varchar column numeric one.

so question is, collation can use sort varchar column numerically?

if varchar column contains numbers, should integer column. otherwise, can do

order cast(col signed)  

see demo


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -