×ðÁú¿­Ê±

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µÄ×÷ÓõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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