×ðÁú¿­Ê±¹ÙÍøµÇ¼

sqlÖÐlikeÊÇʲôÒâ˼

like ÊÇ sql ÖеIJÙ×÷·û £¬ÓÃÓÚÔÚ±íÖÐËÑË÷ÓëÖ¸¶¨Ä£Ê½ÏàÆ¥ÅäµÄÐС£ËüʹÓÃͨÅä·û % ºÍ À´Æ¥Åä×Ö·û £¬ÆäÖÐ % Æ¥Åäí§ÒâÊýÄ¿µÄ×Ö·û £¬¶ø Æ¥ÅäÈκε¥¸ö×Ö·û¡£

SQL ÖÐµÄ LIKE

ʲôÊÇ LIKE£¿

LIKE ÊÇ SQL ÖеÄÒ»¸ö²Ù×÷·û £¬ÓÃÓÚÔÚÊý¾Ý¿â±íÖÐËÑË÷ÓëÖ¸¶¨Ä£Ê½ÏàÆ¥ÅäµÄÐС£

ʹÓÃÒªÁì

LIKE Óï·¨ÈçÏ£º

SELECT column_name
FROM table_name
WHERE column_name LIKE 'pattern';

µÇ¼ºó¸´ÖÆ

ÆäÖУº

column_name ÊÇÒªËÑË÷µÄÁÐÃû¡£

pattern ÊÇҪƥÅäµÄģʽ £¬¿ÉÒÔʹÓÃÒÔÏÂͨÅä·û£º

%£ºÆ¥Åäí§ÒâÊýÄ¿µÄ×Ö·û¡£

_£ºÆ¥ÅäÈκε¥¸ö×Ö·û¡£

ÊÂÇéÔ­Àí

LIKE ÔËËã·ûͨ¹ý½«ÁÐÖµÓëÖ¸¶¨µÄģʽ¾ÙÐнÏÁ¿À´ÊÂÇé¡£ÈôÊÇÁÐÖµÓëģʽƥÅä £¬Ôò¸ÃÐн«±»·µ»Ø¡£

ʾÀý

ÒÔÏÂʾÀýÅÌÎÊ·µ»Ø°üÀ¨×Öĸ “a” µÄËùÖøÃû³ÆµÄÐУº

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

µÇ¼ºó¸´ÖÆ

ÒÔÏÂʾÀýÅÌÎÊ·µ»ØÒÔ “J” ¿ªÍ·µÄËùÓÐÐÕÊϵÄÐУº

SELECT last_name
FROM customers
WHERE last_name LIKE 'J%';

µÇ¼ºó¸´ÖÆ

×¢ÖØ£º

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

LIKE ģʽ±ØÐèÓõ¥ÒýºÅÀ¨ÆðÀ´¡£

ÈôÊÇģʽÖаüÀ¨Í¨Åä·û £¬Ôò±ØÐèÓ÷´Ð±¸Ü () תÒå¡£ÀýÈ磺Ҫ²éÕÒ°üÀ¨×Ö·û “%” µÄÁÐÖµ £¬¿ÉÒÔʹÓÃģʽ \%¡£

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ