sqlÖÐÓÃinÅÌÎÊ×ֶλáºÜÂýÂð
ÊÇ£¬ÔÚijЩÇéÐÎÏ»áºÜÂý¡£in ÅÌÎʽÏÁ¿±íÖеÄÿһÐÐÓë×ÓÅÌÎÊÖеÄÖµ£¬µ±×ÓÅÌÎÊЧ¹û¼¯ºÜ´óʱ£¬ÐÔÄÜ»áϽµ¡£Ó°ÏìÒòËØ°üÀ¨×ÓÅÌÎʾÞϸ¡¢±íÐÐÊýºÍË÷Òý¡£»º½â²½·¥°üÀ¨ÏÞÖÆ×ÓÅÌÎÊЧ¹û¡¢Ê¹ÓÃÏêϸË÷ÒýºÍ˼Á¿ÆäËûÅÌÎÊÀàÐÍ¡£×î¼Ñʵ¼ùÊÇ×èÖ¹ÔÚÒªº¦ÁÐÉÏʹÓà in ÅÌÎÊ£¬Ê¹ÓøüСµÄ×ÓÅÌÎÊ£¬Ìí¼ÓË÷ÒýºÍ¼àÊÓÅÌÎÊÍýÏë¡£
SQL ÖÐʹÓà IN ÅÌÎÊ×Ö¶ÎÊÇ·ñ»áºÜÂý£¿
ÃÕµ×£ºÊÇ£¬ÔÚijЩÇéÐÎÏ»ᡣ
ÏêϸڹÊÍ£º
IN ÅÌÎʽ«±íÖеÄÿһÐÐÓëÒ»¸ö×ÓÅÌÎÊÖеÄÒ»¸ö»ò¶à¸öÖµ¾ÙÐнÏÁ¿¡£µ±×ÓÅÌÎÊЧ¹û¼¯ºÜ´óʱ£¬Õâ¿ÉÄÜ•þµ¼ÖÂÐÔÄÜϽµ¡£
Ó°ÏìÒòËØ£º
ÒÔÏÂÒòËØ»áÓ°Ïì IN ÅÌÎʵÄÐÔÄÜ£º
×ÓÅÌÎÊЧ¹û¼¯´óС£º×ÓÅÌÎÊЧ¹û¼¯Ô½´ó£¬ÐÔÄÜÔ½Âý¡£
±íÖÐÐÐÊý£º±íÖÐÐÐÊýÔ½¶à£¬ÅÌÎÊÐèÒª¼ì²éµÄ½ÏÁ¿Ô½¶à¡£
Ë÷Òý£ºÈôÊÇûÓÐÊʵ±µÄË÷Òý£¬ÅÌÎÊÐèÒª¾ÙÐÐÈ«±íɨÃ裬Õâ»á½øÒ»²½½µµÍÐÔÄÜ¡£
»º½â²½·¥£º
ΪÁË»º½â IN ÅÌÎʵÄÐÔÄÜÎÊÌ⣬¿ÉÒÔ½ÓÄÉÒÔϲ½·¥£º
ÏÞÖÆ×ÓÅÌÎÊЧ¹û¼¯£ºÔÚ×ÓÅÌÎÊÖÐʹÓà WHERE ×Ó¾äÀ´ÏÞÖÆ·µ»ØµÄÐÐÊý¡£
ʹÓøüÏêϸµÄË÷Òý£ºÎªÉæ¼°µÄÁн¨Éè¸üÏêϸµÄË÷Òý£¬ÒÔ¼ÓËÙ½ÏÁ¿Àú³Ì¡£
˼Á¿Ê¹ÓÃÆäËûÅÌÎÊÀàÐÍ£º¹ØÓÚ´óÐÍ×ÓÅÌÎÊ£¬¿ÉÒÔʹÓà JOIN »ò EXISTS ÅÌÎÊ×÷Ϊ IN ÅÌÎʵÄÌæ»»¼Æ»®¡£
×î¼Ñʵ¼ù£º
ÒÔÏÂÊÇһЩ×èÖ¹ IN ÅÌÎÊÐÔÄÜÎÊÌâµÄ×î¼Ñʵ¼ù£º
×èÖ¹ÔÚÒªº¦ÁÐÉÏʹÓà IN ÅÌÎÊ¡£
Ö»¹ÜʹÓøüСµÄ×ÓÅÌÎÊ¡£
ÏòÉæ¼°ÁÐÌí¼ÓË÷Òý¡£
˼Á¿Ê¹Óà UNION ALL ÓÅ»¯ JOIN ÅÌÎÊ¡£
¼àÊÓÅÌÎÊÍýÏë²¢µ÷½âÅÌÎÊ£¬ÒÔÌá¸ßÐÔÄÜ¡£
ÒÔÉϾÍÊÇsqlÖÐÓÃinÅÌÎÊ×ֶλáºÜÂýÂðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡