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