mysqlÖеÄinÊÇʲôÒâ˼
mysql ÖÐµÄ in ÔËËã·ûÓÃÓÚ¼ì²éÒ»¸öÖµÊÇ·ñ°üÀ¨ÔÚÒ»¸öÖ¸¶¨ÁбíÖУ¬Ó﷨Ϊ£ºselect column_name from table_name where column_name in (value1, value2, …, valuen)¡£ÆäÓÅÊÆ°üÀ¨Ð§Âʸߡ¢Ò×ÓÃÐԺͿÉÀ©Õ¹ÐÔ¡£ÐèҪעÖصÄÊÇ£¬¹ØÓÚ´óÐÍÁбí»ò null Öµ£¬Ëü¿ÉÄܻᵼÖÂÐÔÄÜÎÊÌâ¡£
MySQL ÖÐµÄ IN ÔËËã·û
MySQL ÖÐµÄ IN ÔËËã·ûÓÃÓÚ¼ì²éÒ»¸öÖµÊÇ·ñ°üÀ¨ÔÚÒ»¸öÖ¸¶¨ÁбíÖС£Óï·¨ÈçÏ£º
SELECT column_name FROM table_name WHERE column_name IN (value1, value2, ..., valueN);
µÇ¼ºó¸´ÖÆ
ÔõÑùʹÓà IN ÔËËã·û
¿ÉÒÔʹÓà IN ÔËËã·ûÓë¶à¸öÖµ¾ÙÐнÏÁ¿£¬ÒÔ¼ì²éÌض¨ÖµÊÇ·ñ±£´æÓÚ¸ÃÁбíÖС£ÀýÈ磬Ҫ²éÕÒ°üÀ¨Öµ 5¡¢7 »ò 9 µÄ “id” ÁУ¬¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º
SELECT id FROM table_name WHERE id IN (5, 7, 9);
µÇ¼ºó¸´ÖÆ
IN ÔËËã·ûµÄÓÅÊÆ
ЧÂÊ£º¹ØÓÚ¼ì²é¶à¸öÖµÊÇ·ñ°üÀ¨ÔÚÒ»¸öÁбíÖУ¬IN ÔËËã·û±ÈʹÓöà¸ö OR ÔËËã·û¸üΪ¸ßЧ¡£
Ò×ÓÚʹÓãºÊ¹Óà IN ÔËËã·ûºÜÊǼòÆÓÃ÷Îú£¬ÎÞÐè±àдÖØ´óµÄÅÌÎÊ¡£
¿ÉÀ©Õ¹ÐÔ£ºIN ÔËËã·ûÖ§³Öí§ÒâÊýÄ¿µÄÖµ£¬Òò´ËºÜÊÇÊʺϴ¦Àí´óÐÍÊý¾Ý¼¯¡£
×¢ÖØÊÂÏî
IN ÔËËã·û¹ØÓÚСÁбíºÜÊÇÓÐÓ㬵«¹ØÓÚ´óÐÍÁбí¿ÉÄܻᵼÖÂÐÔÄÜÎÊÌâ¡£
ÈôÊÇÒª¼ì²éµÄֵΪ NULL£¬Ôò IN ÔËËã·û½«Ê¼ÖÕ·µ»Ø FALSE£¬ÓÉÓÚ NULL ²»¼´ÊÇÈκÎÖµ¡£
IN ÔËËã·û¹ØÓÚ·ÇÊý×ÖÀàÐ͵ÄÁУ¨ÀýÈç×Ö·û´®»òÈÕÆÚ£©Ò²ÊÇÓÐÓõġ£
ÒÔÉϾÍÊÇmysqlÖеÄinÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡