看板 Database 關於我們 聯絡資訊
※ 引述《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
averywu:感謝您。這個ORDER BY LOCATE() 真好用 12/12 09:46
LPH66:其實 locate 是從這裡翻到的: http://tinyurl.com/7e7ve 12/12 13:16