SQL²éѯÖеÄתÒå×Ö·û
ÀÁèÐÇ¿Õ
Èç¹ûÏë²éÕÒ“_cs”½áβµÄµÄÕË»§
select * from [user] where loginname like '%_cs'ÊDz»Ðеģ¬_ ±»ÈÏΪÊÇÈÎÒâµÄ×Ö·û£¬
ËùÒÔÐèҪתÒå×Ö·û£¬ÓÐÁ½ÖÖд·¨£º
select * from [user] where loginname like '%[_]cs'
select * from [user] where loginname like '%/_cs' escape'/'
ͨÅä·ûº¬Òå
%
°üº¬Áã¸ö»ò¸ü¶à×Ö·ûµÄÈÎÒâ×Ö·û´®¡£
_
Èκε¥¸ö×Ö·û¡£
[ ]
Ö¸¶¨·¶Î§£¨ÀýÈç [a-f]£©»ò¼¯ºÏ£¨ÀýÈç [abcdef]£©ÄÚµÄÈκε¥¸ö×Ö·û¡£
[^]
²»ÔÚÖ¸¶¨·¶Î§£¨ÀýÈç [^a - f]£©»ò¼¯ºÏ£¨ÀýÈç [^abcdef]£©ÄÚµÄÈκε¥¸ö×Ö·û¡£
ÀýÈ磺
LIKE 'Mc%' ½«ËÑË÷ÒÔ×Öĸ Mc ¿ªÍ·µÄËùÓÐ×Ö·û´®£¨Èç McBadden£©¡£
LIKE '%inger' ½«ËÑË÷ÒÔ×Öĸ inger ½áβµÄËùÓÐ×Ö·û´®£¨Èç Ringer¡¢Stringer£©¡£
LIKE '%en%' ½«ËÑË÷ÔÚÈκÎλÖðüº¬×Öĸ en µÄËùÓÐ×Ö·û´®£¨Èç Bennet¡¢Green¡¢McBadden£©¡£
LIKE '_heryl' ½«ËÑË÷ÒÔ×Öĸ heryl ½áβµÄËùÓÐÁù¸ö×ÖĸµÄÃû³Æ£¨Èç Cheryl¡¢Sheryl£©¡£
LIKE '[CK]ars[eo]n' ½«ËÑË÷ÏÂÁÐ×Ö·û´®£ºCarsen¡¢Karsen¡¢Carson ºÍ Karson£¨Èç Carson£©¡£
LIKE '[M-Z]inger' ½«ËÑË÷ÒÔ×Ö·û´® inger ½áβ¡¢ÒÔ´Ó M µ½ Z µÄÈκε¥¸ö×Öĸ¿ªÍ·µÄËùÓÐÃû³Æ£¨Èç Ringer£©¡£
LIKE 'M[^c]%' ½«ËÑË÷ÒÔ×Öĸ M ¿ªÍ·£¬²¢ÇÒµÚ¶þ¸ö×Öĸ²»ÊÇ c µÄËùÓÐÃû³Æ£¨Èç MacFeather£©¡£
ʹÓà ESCAPE ¹Ø¼ü×Ö¶¨ÒåתÒå·û¡£ÔÚģʽÖУ¬µ±×ªÒå·ûÖÃÓÚͨÅä·û֮ǰʱ£¬¸ÃͨÅä·û¾Í½âÊÍΪÆÕͨ×Ö·û¡£ÀýÈ磬ҪËÑË÷ÔÚÈÎÒâλÖðüº¬×Ö·û´® 5% µÄ×Ö·û´®£¬ÇëʹÓãº
WHERE ColumnA LIKE '%5/%%' ESCAPE '/'
·ûºÅº¬Òå
LIKE '5[%]'
5%
LIKE '5%'
5 ºó¸ú 0 ¸ö»ò¸ü¶à×Ö·ûµÄ×Ö·û´®
LIKE '[_]n'
_n
LIKE '_n'
an, in, on (and so on)
LIKE '[a-cdf]'
a, b, c, d, or f
LIKE '[-acdf]'
-, a, c, d, or f
LIKE '[ [ ]'
[
LIKE ']'
]
Àý×Ó£º
select * from T_DataVersion where VersionName like '%2[%]%'
select * from T_DataVersion where VersionName like '%2/%%' ESCAPE '/'
²éÕÒVersionName Öаüº¬2%×Ö·û´®µÄÊý¾Ý
VerSionID UserID VersionName DataCode UpLoadDate IntegerStep
V20081229001 104 V200812%29001 A0001 2009-12-29 00:00:00.000 NULL
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
SQL Server 2005 ¿ª·¢°æ²»ÔÊÐíÔ¶³ÌÁ¬½Ó¡£
¡¡¡¡ÒªÔÊÐíÔ¶³ÌÁ¬½ÓSQL Server 2005 ,ÐèÒªÍê³ÉÒÔϲ½Ö裺
•ÔÚSQLServer ʵÀýÉÏÆôÓÃÔ¶³ÌÁ¬½Ó¡£
•´ò¿ª·þÎñÆ÷ SQLBrowser ·þÎñ¡£
•ÅäÖ÷À»ðǽÒÔÔÊÐíSQLBrowser ·þÎñºÍSQLServer·þÎñÍøÂçͨÐÅ¡£
¡¡¡¡ÔÚSQLServer ʵÀýÉÏÆôÓÃÔ¶³ÌÁ¬½Ó
1.Ö¸Ïò“¿ªÊ¼->³ÌÐ ......
´¦ÀíSQL ServerÊý¾Ý¿âÖеĹÂÁ¢Óû§(ͼ)
°ÑÊý¾Ý¿â´ÓÒ»¸ö·þÎñÆ÷ʵÀý¸½¼ÓºÍ»Ö¸´µ½ÁíÒ»¸öʵÀýÖÐÊÇÊý¾Ý¿â¹ÜÀíÔ±Ö´Ðеij£¼ûµÄÈÎÎñ¡£¸½¼Ó»òÕ߻ָ´Ò»¸öÊý¾Ý¿âÖ®ºó£¬Ö®Ç°ÔÚÊý¾Ý¿âÖд´½¨ºÍÅäÖõĵǼÃûÒѾ²»ÄÜ·ÃÎÊÁË¡£Õâ¸öÎÊÌâ×î³£¼ûµÄÖ¢×´ÊÇÓ¦ÓóÌÐò»áÓöµ½µÇ¼ʧ°ÜµÄ´íÎ󣬻òÕßÊǵ±ÄãÊÔ×ŰѵǼÃûÌí¼Óµ½Êý¾Ý¿âÖÐʱ£¬Äã¿ÉÄÜ»áµÃµ½Ò» ......
if exists(select * from sysobjects where name='atzk')--ÅжÏÊÇ·ñ´æÔڴ˱í
drop table atzk
go
create table atzk
(
nid int identity(1,1) primary key,--nid×Ô¶¯±àºÅ£¬²¢ÉèΪÖ÷¼ü¡£
mytitle varchar(50) not null,--֪ͨµÄ±êÌâ¡£
mycontents varchar(200)--·¢²¼Í¨ÖªµÄÄÚÈÝ¡£
) ......
֮ǰûÔõôÑо¿¹ýMySQLµÄÈÝÁ¿£¬ÓÉÓÚÏîÄ¿ÐèÒª£¬ÐèÒªÒ»¸öÃâ·ÑµÄ¿ÉÒÔÖ§³ÖǧÍòÌõÊý¾Ý¼¶ÒÔÉϵÄÊý¾Ý¿â£¬²é¿´ÏÂmysqlµÄÎĵµ£¬·¢ÏÂmysql»¹ÊǺÜÇ¿´óµÄ£¬¼Ç¼Ï£¬ºÇºÇ¡£ÔÎÄÈçÏ£º
MySQL 3.22ÏÞÖƵıí´óСΪ4GB¡£ÓÉÓÚÔÚMySQL 3.23ÖÐʹÓÃÁËMyISAM´æ´¢ÒýÇ棬×î´ó±í³ß´çÔö¼Óµ½ÁË65536TB£¨2567 –1×Ö½Ú£©¡£ÓÉÓÚÔÊÐíµÄ±í³ß´ç¸ü´ ......