我有以下 MySQL 查询,它为 Python 网页提供数据。在网页上,我有一个歌曲名称列表,我希望它按字母顺序排列,忽略标点符号和空格。我的 MySQL 数据库是 UTF-8 编码的,一些需要忽略的标点符号是特殊字符,例如弯撇号等。
SELECT * FROM Tracks\
JOIN Artists USING (ArtistID)\
JOIN Albums USING (AlbumID)\
JOIN Songs USING (SongID)\
ORDER BY UPPER(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(\
REPLACE(SoName, ' ', ''), /* space */\
',', ''), /* comma */\
'.', ''), /* period */\
':', ''), /* colon */\
';', ''), /* semicolon */\
'!', ''), /* exclamation point */\
'?', ''), /* question mark */\
'\u201c', ''), /* left curly double quote */\
'\u201d', ''), /* right curly double quote */\
'\u2019', ''), /* right curly single quote (apostrophe) */\
'\u2013', ''), /* n-dash */\
'\u2014', ''), /* m-dash */\
'\u2026', '') /* ellipsis */), (SongID), UPPER(AlTitle)
在REPLACE
我的查询中似乎非常适合非特殊字符,如空格、逗号、句点等,但它似乎跳过了特殊字符。
我的猜测是字符需要以不同的格式编写。我尝试了以下但没有成功:
REPLACE(SoName, '\u2026', '')
REPLACE(SoName, u'\2026', '')
REPLACE(SoName, 0xE280A6, '')
...