作者LPH66 (-858993460)
看板Database
标题Re: [SQL ] Order By 字串?
时间Sun Dec 12 08:16:07 2010
※ 引述《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
1F:推 averywu:感谢您。这个ORDER BY LOCATE() 真好用 12/12 09:46