Re: [SQL ] 關於在LIKE中使用 % 的語法的問題
試著google了一下
馬上就有答案了~
http://blog.miniasp.com/post/2007/11/Comments-on-using-SQL-LIKE-statement.aspx
提到的應該就是這問題
我實際在ms sql server 20005 測試
SELECT bid, bname, interest
FROM test1
WHERE interest LIKE '%!%' escape '!'
第一個%是萬用字元~第二個!%則是你要的正規字元
escape '!' 可以你自己設定
你想要 'g%' escape 'g'
'\%' escape '\'
都可以,只要不影響你的條件即可
※ 引述《matchyou (這樣也要罵=.=)》之銘言:
: 你要的我做不到 但有取巧的方法看你要不要用看看
: 就是用%之前的數字來like
: select * from BANK
: where substring(interest,1,len(interest)-1) like '%ox%'
: ※ 引述《cityblue ( cityblue)》之銘言:
: : 請問大家, 假設我有一資料表如下:
: : BANK
: : bid bname interest
: : 01 Citybank 15%
: : 02 ChasterBank 10%
: : 03 NationalBank 11%
: : interest屬性中的欄位已包含 % 的character
: : 但我要在 WHERE B.interest LIKE 後加入string matching
: : 請問如何能在LIKE後區別control character 及 data character?
: : 謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.172.62.32
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):