Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLÖÐescapeµÄÖ÷ÒªÓÃ;

1.ʹÓà ESCAPE ¹Ø¼ü×Ö¶¨ÒåתÒå·û¡£ ÔÚģʽÖУ¬µ±×ªÒå·ûÖÃÓÚͨÅä·û֮ǰʱ£¬¸ÃͨÅä·û¾Í½âÊÍΪÆÕͨ×Ö·û¡£ÀýÈ磬ҪËÑË÷ÔÚÈÎÒâλÖðüº¬×Ö·û´® 5% µÄ×Ö·û´®£¬ÇëʹÓ㺠WHERE ColumnA LIKE '%5/%%' ESCAPE '/'
2.ESCAPE 'escape_character' ÔÊÐíÔÚ×Ö·û´®ÖÐËÑË÷ͨÅä·û¶ø²»Êǽ«Æä×÷ΪͨÅä·ûʹÓᣠescape_character ÊÇ·ÅÔÚͨÅä·ûÇ°±íʾ´ËÌØÊâÓÃ;µÄ×Ö·û¡£ SELECT * from finances WHERE description LIKE 'gs_' ESCAPE 'S' Òâ˼¾ÍÊÇ£º ±ÈÈ磬ÎÒÃÇÒªËÑË÷Ò»¸ö×Ö·û´® "g_" ,Èç¹ûÖ±½Ó like "g_"£¬ÄÇô "_"µÄ×÷ÓþÍÊÇͨÅä·û£¬¶ø²»ÊÇ×Ö·û£¬½á¹û£¬ÎÒÃÇ»á²éµ½±ÈÈç "ga","gb","gc",¶ø²»ÊÇÎÒÃÇÐèÒªµÄ "g_". Óà LIKE 'gs_' ESCAPE 'S' 's'±íʾÌØÊâÓ÷¨±êÖ¾


Ïà¹ØÎĵµ£º

SQLÓï¾äЧÂÊ

 1. SQLÓÅ»¯µÄÔ­ÔòÊÇ£º½«Ò»´Î²Ù×÷ÐèÒª¶ÁÈ¡µÄBLOCKÊý¼õµ½×îµÍ,¼´ÔÚ×î¶ÌµÄʱ¼ä´ïµ½×î´óµÄÊý¾ÝÍÌÍÂÁ¿¡£
µ÷Õû²»Á¼SQLͨ³£¿ÉÒÔ´ÓÒÔϼ¸µãÇÐÈ룺
¼ì²é²»Á¼µÄSQL£¬¿¼ÂÇÆäд·¨ÊÇ·ñ»¹ÓпÉÓÅ»¯ÄÚÈÝ
¼ì²é×Ó²éѯ ¿¼ÂÇSQL×Ó²éѯÊÇ·ñ¿ÉÒÔÓüòµ¥Á¬½ÓµÄ·½Ê½½øÐÐÖØÐÂÊéд
¼ì²éÓÅ»¯ ......

sqlÄ£ºý²éѯ

SELECT * from user WHERE name LIKE '%Èý%';
½«»á°ÑnameΪ“ÕÅÈý”£¬“Èý½Å蔣¬“ÌÆÈý²Ø”µÈµÈÓГÈý”µÄÈ«ÕÒ³öÀ´£»
ÔÚ½øÐÐÊý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºýÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥ÅäÄ£Ê ......

SQL SERVERÖÐÁÙʱ±í¡¢³Ö¾Ã±í¡¢±í±äÁ¿µÄÇø±ð

 Óë³Ö¾Ã±íÒ»Ñù£¬ÓÅ»¯Æ÷´´½¨²¢Î¬»¤ÁÙʱ±íµÄ·Ö²¼Í³¼ÆÐÅÏ¢£¬²¢¸ú×ÙËüµÄ»ùÊý¡£µ±Ë÷ÒýÁÙʱ±íʱ£¬ÕâÖÖÄÜÁ¦ÓÈÆäÖØÒª¡£µ±ÓÅ»¯Æ÷ÐèÒªÆÀ¹ÀÑ¡ÔñÐÔʱ£¬Ëü¾Í¿ÉÒÔ¸ù¾ÝÕâЩ·Ö²¼Í³¼ÆÐÅÏ¢Éú³É¾­¹ýÓÅ»¯µÄ¼Æ»®¡£ÕâÊÇÁÙʱ±íÔÚÐÔÄÜ·½Ã治ͬÓÚ±í±äÁ¿µÄÖ÷ÒªÌØÐÔÖ®Ò»¡£
´ËÍ⣬ÒòΪÁÙʱ±í»áά»¤Í³¼ÆÐÅÏ¢£¬Èç¹ûÉϴαàÒëºó±»ÒýÓñíÓÐ×ã¹»¶àµÄÐз¢ ......

sql server²éѯÊý¾Ý¿âÖаüº¬Ö¸¶¨×Ö·û´®µÄÊý¾Ý±í

 ·¢²¼Ò»¸öʵÓÃС¹¤¾ß£¬¿ÉÒԺܷ½±ãµÄÔÚÊý¾Ý¿âÖÐÕÒµ½°üº¬Ö¸¶¨×Ö·û´®µÄÊý¾Ý±íÃû¼°ÏàÓ¦¼Ç¼£º
/*
¹¦ÄÜ£º²éѯÊý¾Ý¿âÖаüº¬Ö¸¶¨×Ö·û´®µÄÊý¾Ý±íÃû¼°ÏàÓ¦¼Ç¼
×÷Õߣº³Â¼ÓÅô chjpeng#163.com
ÈÕÆÚ£º2009-08-17
*/
declare @key varchar(30)
set @key = 'test'    --Ì滻ΪҪ²éÕÒµÄ×Ö·û´®
DECLARE @ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ