执行以下查询:
SELECT title FROM table ORDER BY title
给了我:
"Hello"
"Zebra"
Apple
Beta
Cactus
我如何按第一个字母字符排序,以获得:
Apple
Beta
Cactus
"Hello"
"Zebra"
答案 0 :(得分:6)
在排序数据之前,您必须删除引号。您可以使用MySQL中的TRIM
函数轻松删除它们:
SELECT title
FROM table
ORDER BY TRIM(BOTH '"' FROM title);
答案 1 :(得分:3)
...ORDER BY REPLACE(title, '"', '');
答案 2 :(得分:3)
SELECT title FROM table ORDER BY TRIM(LEADING '"' FROM title)