×ðÁú¿­Ê±

sqlÖеÄlikeÊÇʲôÒâ˼

sql ÖÐµÄ like ÔËËã·ûÓÃÓÚÑ°ÕÒÆ¥ÅäÌض¨Ä£Ê½µÄÖµ£¬ËüʹÓÃͨÅä·û %£¨Æ¥Åäí§Òâ×Ö·û£©ºÍ _£¨Æ¥Åäµ¥¸ö×Ö·û£©¡£like ÔËËã·ûͨ³£Óë where ×Ó¾äÍŽáʹÓã¬ÓÃÓÚ¹ýÂ˱íÖеÄÐУ¬×¢ÖØËüÇø·Ö¾Þϸд£¬ÇÒͨÅä·ûÖ»ÄÜÔÚģʽ¿ªÍ·»ò×îºóʹÓá£

SQL ÖÐµÄ LIKE ÊÇʲô £¿

LIKE ÔËËã·ûÔÚ SQL ÖÐÓÃÓÚÑ°ÕÒÓëÌض¨Ä£Ê½ÏàÆ¥ÅäµÄÖµ¡£ËüʹÓÃͨÅä·û %£¨°Ù·ÖºÅ£©ºÍ _£¨Ï»®Ïߣ©£¬ÔÊÐíÄúÖ¸¶¨ÒªËÑË÷µÄÖµµÄÌض¨²¿·Ö¡£

°Ù·ÖºÅ£¨%£©

°Ù·ÖºÅÆ¥ÅäÈκÎÊýÄ¿µÄ×Ö·û¡£ÀýÈ磬LIKE ‘%john%’ ½«Æ¥Åä john¡¢john smith¡¢johnny µÈÖµ¡£

Ï»®Ïߣ¨_£©

Ï»®ÏßÆ¥Åäµ¥¸ö×Ö·û¡£ÀýÈ磬LIKE ‘j_hn’ ½«Æ¥Åä john£¬µ«²»»áÆ¥Åä johnny¡£

ʹÓà LIKE ÔËËã·û

LIKE ÔËËã·ûͨ³£Óë WHERE ×Ó¾äÍŽáʹÓã¬ÓÃÓÚ¹ýÂ˱íÖеÄÐС£Óï·¨ÈçÏ£º

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE 'pattern';

µÇ¼ºó¸´ÖÆ

ʾÀý

²éÕÒ±í customers ÖÐÐÕÃû°üÀ¨ “john” µÄËùÓпͻ§£º

SELECT name
FROM customers
WHERE name LIKE '%john%';

µÇ¼ºó¸´ÖÆ

×¢ÖØÊÂÏî

LIKE ÔËËã·ûÇø·Ö¾Þϸд¡£

% ºÍ _ ͨÅä·ûÖ»ÄÜÔÚģʽµÄĩβ»ò¿ªÍ·Ê¹Óá£

ÈôÊÇÐèÒªÔÚģʽÖвéÕÒ % »ò _ ×Ö·û£¬ÇëʹÓÃתÒå×Ö·û \£¨·´Ð±¸Ü£©¡£ÀýÈ磬LIKE ‘\\%john’ ½«Æ¥Åä %john¡£

ÒÔÉϾÍÊÇsqlÖеÄlikeÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿