有一个字段内容是M0,M1,M2,M3等等
排序如下:
SELECT * from detail p WHERE p.type = 3 ORDER BY substr(p.age, 1) asc;
SELECT * from detail p WHERE p.type = 3 ORDER BY replace( p.age, ‘M’, ‘0’) asc;
SELECT * from detail p WHERE p.type = 3 ORDER BY cast(replace(p.age,’M’,”) as SIGNED INTEGER) asc;
SELECT * from detail p WHERE p.type = 3 ORDER BY FIELD(p.age,’M1′,’M2′,’M3′,’M4′,’M5′,’M6′,’M7′,’M8′,’M9′,’M10′,’M11′,’M12′,’M12+’);