Organizational Research By

Surprising Reserch Topic

sorting string column containing numbers in sql


sorting string column containing numbers in sql  using -'sql,mysql,sql-order-by'

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?
    
asked Sep 15, 2015 by NevaGunnjcf
0 votes
12 views



Related Hot Questions



Government Jobs Opening


...