sqlÖÐ%ÌåÏÖʲô
sql ÖÐµÄ % ÌåÏÖͨÅä·û£¬Æ¥Åä×Ö·û´®ÖÐí§ÒâÊýÄ¿µÄ×Ö·û£¬¿ÉÒÔ·ºÆðÔÚ×Ö·û´®¿ªÍ·¡¢ÖÐÐÄ»ò×îºó£¬ÓÃÓÚ like ×Ó¾äÖеÄģʽƥÅä¡£
SQL ÖÐ % ÌåÏÖʲô
»Ø¸²£º
SQL ÖÐµÄ % ÊÇͨÅä·û£¬ÌåÏÖÆ¥Åä×Ö·û´®ÖÐí§ÒâÊýÄ¿µÄ×Ö·û¡£
ÏêϸÐÅÏ¢£º
¿ÉÒÔ½« % ÓÃÔÚ LIKE ×Ó¾äÖУ¬ÓÃÓÚģʽƥÅä¡£
% Æ¥ÅäÁã¸ö»ò¶à¸ö×Ö·û¡£
% ¿ÉÒÔ·ºÆðÔÚ×Ö·û´®µÄ¿ªÍ·¡¢ÖÐÐÄ»ò×îºó¡£
ʾÀý£º
SELECT * FROM table WHERE field LIKE ‘abc%’ Æ¥Åä×ֶΠfield ÒÔ “abc” ¿ªÍ·µÄËùÓÐÖµ¡£
SELECT * FROM table WHERE field LIKE ‘%xyz’ Æ¥Åä×ֶΠfield ÒÔ “xyz” ×îºóµÄËùÓÐÖµ¡£
SELECT * FROM table WHERE field LIKE ‘%abc%’ Æ¥Åä×ֶΠfield °üÀ¨ “abc” ×Ó×Ö·û´®µÄËùÓÐÖµ¡£
×¢ÖØ£º
ÈôÊÇÐèҪƥÅä % ×Ô¼º£¬ÐèҪʹÓÃתÒå·û \£¬¼´ \%¡£
% »¹¿ÉÒÔÓëÆäËûͨÅä·ûÍŽáʹÓã¬Èç _£¨Ï»®Ïߣ©£¬ÌåÏÖÆ¥Åäµ¥¸ö×Ö·û¡£
ÒÔÉϾÍÊÇsqlÖÐ%ÌåÏÖʲôµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡