Sorting string column containing numbers in SQL?
        Posted  
        
            by 
                Ish
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ish
        
        
        
        Published on 2011-02-08T23:00:42Z
        Indexed on 
            2011/02/08
            23:25 UTC
        
        
        Read the original article
        Hit count: 276
        
Dear Folks,
I am trying to sort string column (containing numbers).
// SELECT `name` FROM `mytable` ORDER BY `name` ASC
+----------+
+-- name --+
+----------+
+-- a 1 ---+
+-- a 12 --+
+-- a 2 ---+
+-- a 3 ---+
You see natural sorting algorithm of Mysql is placing a 12 after a 1 (which is ok for most apps), But I have unique needs, so I want result should be sorted like this.
+----------+
+-- name --+
+----------+
+-- a 1 ---+
+-- a 2 ---+
+-- a 3 ---+
+-- a 12 --+
Is it possible with just SQL, or I have to manipulate result-set at application level?
Thanks for reading...
© Stack Overflow or respective owner