这是我的测试数据(MySQL)
test1
test2
test3
test10
test11
mytest
我想通过文本排序这些记录,而不是通过以下数字(如果存在):
mytest
test1
test2
test3
test10
test11
当我使用Order By
时,我的数据按文本排序,如下所示:
mytest
test1
test10
test11
test2
test3
谁能给我一个解决方案吗?
最佳答案
在我的查询中,我将字母数字值与字符串值相除,然后合并结果,看看:
select temp1.a col from
(select a from tabl WHERE a not REGEXP '[0-9]' order by length(a)) temp1
union all
select temp2.a from
(select a FROM tabl WHERE a REGEXP '[0-9]' order by length(a),a) temp2 ;
关于mysql - 如何在带有数字输入的文本上应用排序依据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29768112/