Rumah >pembangunan bahagian belakang >tutorial php >求教一个MYSQL数字和字母混合排序有关问题
求教一个MYSQL数字和字母混合排序问题
数据库里有一个表a,表a有一个字段b为字符串类型,里面的数据大多为88A242 ,88A106,88A109,92A129,92A068,2000A291,2000A216,2014A063,2014A315这样的字符串,求教各位大神,如何排序?
排序后应为: 88A106,88A109,88A242,92A068,92A129,2000A216,2000A291,2014A063,2014A315
------解决思路----------------------
create temporary table T (a varchar(10));<br /><br />insert into T (a) values ('88A242'),('88A106'),('88A109'),('92A129'),('92A068'),('2000A291'),('2000A216'),('2014A063'),('2014A315');<br /><br />select * from T order by lpad(a, 10, '0');
a <br />88A106 <br />88A109 <br />88A242 <br />92A068 <br />92A129 <br />2000A216 <br />2000A291 <br />2014A063 <br />2014A315 <br />