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

mysqlÖÐinµÄ×÷ÓÃ

mysql ÖÐµÄ in ²Ù×÷·ûÓÃÓÚ¼ì²éÒ»¸öÁеÄÖµÊÇ·ñÔÚÖ¸¶¨ÖµÁбíÖУ¬Ê¹Äú¿ÉÒÔÇáËɲéÕÒ°üÀ¨Ìض¨ÖµµÄ¼Í¼ ¡£ÆäÓ﷨Ϊ£ºselect column_name from table_name where column_name in (value1, value2, …, valuen) ¡£Ê¹Óà in ²Ù×÷·ûʱ£¬mysql »áÖðÒ»¼ì²éÁÐÖµÊÇ·ñÓëÁбíÖеÄÈκÎֵƥÅ䣬ÈôÊÇÆ¥Å䣬¸Ã¼Í¼½«±»ÄÉÈëЧ¹û¼¯ÖÐ ¡£

MySQL ÖÐ IN µÄ×÷ÓÃ

IN ²Ù×÷·ûÔÚ MySQL ÖÐÓÃÓÚ¼ì²éÒ»¸öÁеÄÖµÊÇ·ñÔÚÖ¸¶¨ÖµµÄÁбíÖÐ ¡£µ±ÄúÐèÒª²éÕÒ°üÀ¨¶à¸öÌض¨ÖµµÄ¼Í¼ʱ£¬IN ²Ù×÷·ûºÜÊÇÓÐÓà ¡£

Óï·¨

SELECT column_name
FROM table_name
WHERE column_name IN (value1, value2, ..., valueN);

µÇ¼ºó¸´ÖÆ

ÆäÖУº

column_name ÊÇÄúÒª¼ì²éµÄÁеÄÃû³Æ ¡£

value1, value2, …, valueN ÊÇÄúÕýÔÚ²éÕÒµÄÌض¨ÖµÁбí ¡£

Ó÷¨

ʹÓà IN ²Ù×÷·û¾ÙÐÐÅÌÎÊʱ£¬MySQL »áÖðÒ»¼ì²éÁÐÖµÊÇ·ñÓëÁбíÖеÄÈκÎֵƥÅä ¡£ÈôÊÇÁÐֵƥÅäÁбíÖеÄÈκÎÖµ£¬Ôò¸Ã¼Í¼½«°üÀ¨ÔÚЧ¹û¼¯ÖÐ ¡£

ʾÀý

¼ÙÉèÄúÓÐÒ»¸öÃûΪ students µÄ±í£¬ÆäÖаüÀ¨ student_id¡¢name ºÍ age ÁÐ ¡£ÄúÒª²éÕÒÄêËêΪ 20¡¢21 »ò 22 µÄѧÉú£¬¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º

SELECT name
FROM students
WHERE age IN (20, 21, 22);

µÇ¼ºó¸´ÖÆ

¸ÃÅÌÎʽ«·µ»ØÄêËêΪ 20¡¢21 »ò 22 µÄËùÓÐѧÉúµÄÐÕÃû ¡£

×¢ÖØÊÂÏî

IN ²Ù×÷·û¿ÉÒÔÓë×Ö·û´®¡¢Êý×ÖºÍÈÕÆÚÖµÒ»ÆðʹÓà ¡£

Äú¿ÉÒÔÖ¸¶¨í§ÒâÊýÄ¿µÄÖµÁбí ¡£

IN ²Ù×÷·ûÓë NOT IN ²Ù×÷·ûÀàËÆ£¬ºóÕßÓÃÓÚ²éÕÒ²»°üö¾Ù±íÖÐÈκÎÖµµÄ¼Í¼ ¡£

ÒÔÉϾÍÊÇmysqlÖÐinµÄ×÷ÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ