Home > Backend Development > PHP Tutorial > mysql 数目字字母排序

mysql 数目字字母排序

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:38:01
Original
1093 people have browsed it

mysql 数字字母排序
有a表如下字段 
id 1 a 2 b 3 c
排序后要得到  
id a b c 1 2 3 
也就是说字符按照字符来排序,数字按照数字来排序
看过一个解决方案
select Id from a order by (case when REGEXP_LIKE(trim(Id),'^[0-9]+$') then ascii(Id)+74 else ascii(Id) end) 
结果mysql不能识别 REGEXP_LIKE

------解决方案--------------------

SQL code
select 'id' as chunion select '1'union select 'a'union select '3'union select 'c'union select '2'union select 'b'order by length(ch) desc, ch+0=0 desc, ch<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
AngularJS Select default value?
From 1970-01-01 08:00:00
0
0
0
Select option using PHP loop
From 1970-01-01 08:00:00
0
0
0
Chrome doesn't apply padding to select options
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template