中的模式匹配

来源:互联网 发布:大数据安全就业 编辑:程序博客网 时间:2024/05/16 05:47
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

Author:DavidEuler
Date:2004/11/17
Email:de_euler-david@yahoo.com.cn
有任何问题,请与我联系:)

SQLServerBooksOnline上面搜索like,找到了包含%,_,[],[^]几个通配符。
如:select *frommybbswhereContentlike'[w]%'
like关键字用于搜索匹配某个模式的字符串,或者日期,时间值。
SQLServerBooks中的部分解释如下:
PatternMatchinginSearchConditions
TheLIKEkeywordusesaregularexpressiontocontainthepatternthatthevaluesarematchedagainst.Thepatterncontainsthecharacterstringtosearchfor,whichcancontainanycombinationoffourwildcards.
WildcardMeaning%Anystringofzeroormorecharacters._Anysinglecharacter.[]Anysinglecharacterwithinthespecifiedrange(forexample,[a-f])orset(forexample,[abcdef]).[^]Anysinglecharacternotwithinthespecifiedrange(forexample,[^a-f])orset(forexample,[^abcdef]).

Enclosethewildcard(s)andthecharacterstringinsinglequotationmarks,forexample:LIKE'%en%'searchesforallstringsthatcontainthelettersenanywhereinthestring(Bennet,Green,McBadden).
LIKE'_heryl'searchesforallsix-letternamesendingwiththelettersheryl(Cheryl,Sheryl).
LIKE'[CK]ars[eo]n'searchesforCarsen,Karsen,Carson,andKarson(Carson).
LIKE'[M-Z]inger'searchesforallnamesendingwiththelettersingerthatbeginwithanysingleletterfromMthroughZ(Ringer).
LIKE'M[^c]%'searchesforallnamesbeginningwiththeletterMthatdonothavethelettercasthesecondletter(Feather).
Thisqueryfindsallphonenumbersintheauthorstablethathaveareacode415:

SELECTphoneFROMpubs.dbo.authorsWHEREphoneLIKE'415%'

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击