作者humanfly (laguna)
看板Database
标题Re: [SQL ] 关於在LIKE中使用 % 的语法的问题
时间Fri Oct 3 22:30:45 2008
试着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