Re: [SQL ] Order By 字串?
※ 引述《averywu (看文不要只會用橫的看)》之銘言:
: 有沒有可能讓 Order By 依字串來排序呢?
: 例: Select Name from Telbook Order By Firstname = '黃';
: 有可能嗎?
: 註:SELECT Name FROM Telbook ORDER BY CASE
: WHEN strpos(firstname,'黃') > 1
: 這行不能跑...
如果你是要選出有"黃"的
... WHERE `Name` LIKE '%黃%';
如果是要按"黃"的位置來排
... ORDER BY LOCATE('黃',`Name`);
還是你要的不是這樣?
--
'You've sort of made up for it tonight,' said Harry. 'Getting the
sword. Finishing the Horcrux. Saving my life.'
'That makes me sound a lot cooler then I was,' Ron mumbled.
'Stuff like that always sounds cooler then it really was,' said
Harry. 'I've been trying to tell you that for years.'
-- Harry Potter and the Deathly Hollows, P.308
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.28.92
推
12/12 09:46, , 1F
12/12 09:46, 1F
→
12/12 13:16, , 2F
12/12 13:16, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):