inÔÚsqlÖеÄÒâ˼
in ²Ù×÷·û¼ì²éij¸öÖµÊÇ·ñ°üÀ¨ÔÚÖ¸¶¨µÄÖµÁбíÖУ¬Ó﷨Ϊ£ºselect * from table_name where column_name in (value1, value2, …, valuen)¡£ËüµÄÓŵãÊÇÌá¸ßÅÌÎÊÐÔÄÜ£¬ÌØÊâÊǵ±ÐèÒª¼ì²éÒ»¸öÖµÊÇ·ñ°üÀ¨ÔÚ´ó×ÚÖµÖÐʱ¡£±ðµÄ£¬in ²Ù×÷·û»¹¿ÉÓë×ÓÅÌÎÊ»ò not ÔËËã·ûÒ»ÆðʹÓá£
IN ²Ù×÷·ûÔÚ SQL ÖеļÄÒå
IN ²Ù×÷·ûÔÚ SQL ÖÐÓÃÓÚ¼ì²éij¸öÖµÊÇ·ñ°üÀ¨ÔÚÖ¸¶¨µÄÒ»×éÖµÖС£ËüʹÓÃÒÔÏÂÓï·¨£º
SELECT * FROM table_name WHERE column_name IN (value1, value2, ..., valueN);
µÇ¼ºó¸´ÖÆ
ÆäÖУº
table_name ÊÇÒª´ÓÖмìË÷Êý¾ÝµÄ±í¡£
column_name ÊÇÒª¼ì²éÖµµÄÁС£
value1, value2, …, valueN ÊÇÒª¼ì²éµÄÖµÁÐ±í¡£
ÔõÑùʹÓà IN ²Ù×÷·û
ҪʹÓà IN ²Ù×÷·û£¬Ö»Ð轫Ҫ¼ì²éµÄÖµ·ÅÔÚÀ¨ºÅÄÚ¡£ÀýÈ磬ҪÕÒ³ö±í customers ÖÐÆÜÉíÔÚŦԼ»ò¼ÓÖݵĿͻ§£¬¿ÉÒÔ±àдÒÔÏÂÅÌÎÊ£º
SELECT * FROM customers WHERE state IN ('NY', 'CA');
µÇ¼ºó¸´ÖÆ
IN ²Ù×÷·ûµÄÓŵã
ʹÓà IN ²Ù×÷·ûµÄÖ÷ÒªÓŵãÊÇËü¿ÉÒÔÌá¸ßÅÌÎÊÐÔÄÜ¡£µ±ÐèÒª¼ì²éÒ»¸öÖµÊÇ·ñ°üÀ¨ÔÚ´ó×ÚÖµÖÐʱ£¬Ê¹Óà IN ²Ù×÷·û±ÈʹÓöà¸ö OR Ìõ¼þ¸üÓÐÓá£
ÆäËûÏà¹ØÐÅÏ¢
IN ²Ù×÷·û»¹¿ÉÒÔÓë×ÓÅÌÎÊÒ»ÆðʹÓã¬ÓÃÓÚ¼ì²éij¸öÖµÊÇ·ñ°üÀ¨ÔÚ´ÓÁíÒ»¸öÅÌÎÊ·µ»ØµÄЧ¹û¼¯ÖС£
IN ²Ù×÷·û»¹¿ÉÒÔÓë NOTÔËËã·ûÒ»ÆðʹÓã¬ÒÔ¼ì²éij¸öÖµÊÇ·ñ²»°üÀ¨ÔÚÖ¸¶¨µÄÖµÁбíÖС£
ÒÔÉϾÍÊÇinÔÚsqlÖеÄÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡