mysqlÖÐinµÄÓ÷¨
in ÔËËã·ûÓÃÓÚ¼ì²éij¸öÖµÊÇ·ñ°üÀ¨ÔÚÒ»¸öÖµÁбíÖС£Ó﷨Ϊ£ºselect * from table_name where column_name in (value1, value2, …, valuen); in ÔËËã·û¿ÉÓëÖµÁÐ±í¡¢±äÁ¿»ò×ÓÅÌÎÊÒ»ÆðʹÓã¬Ö§³Ö¶àÖÖÖµÀàÐͽÏÁ¿¡£Ëü±È or ÔËËã·û¸üÓÐÓã¬ÓÈÆäÊÇÔÚÁбíÖаüÀ¨¶à¸öֵʱ¡£
MySQL ÖÐ IN Ó÷¨
ÎÊÌ⣺IN ÔËËã·ûÔÚ MySQL ÖÐÓÐʲô×÷Óã¿
»Ø¸²£º IN ÔËËã·ûÓÃÓÚ¼ì²éij¸öÖµÊÇ·ñ°üÀ¨ÔÚÒ»¸öÖµÁбíÖС£Ó﷨Ϊ£º
SELECT * FROM table_name WHERE column_name IN (value1, value2, ..., valueN);
µÇ¼ºó¸´ÖÆ
ÏêϸڹÊÍ£º
IN ÔËËã·û¿ÉÒÔ½«ÖµÓëÒ»¸öÖµÁбí¾ÙÐнÏÁ¿¡£ÈôÊÇÖµÓëÁбíÖеÄÈκÎֵƥÅ䣬Ôò±í´ïʽΪÕæ¡£²»È»£¬±í´ïʽΪ¼Ù¡£
ʾÀý£º
»ñȡЧ¹ûΪ A¡¢B»ò C µÄѧÉú£º
SELECT * FROM students WHERE grade IN ('A', 'B', 'C');
µÇ¼ºó¸´ÖÆ
IN ÔËËã·ûÖ§³Ö×ÓÅÌÎÊ£º
SELECT * FROM students WHERE grade IN (SELECT grade FROM grades WHERE score > 80);
µÇ¼ºó¸´ÖÆ
×¢ÖØ£º
IN ÁбíÖеÄÖµ¿ÉÒÔÊdz£Á¿¡¢±äÁ¿»ò×ÓÅÌÎÊ¡£
ÖµÁбíÖпÉÒÔ°üÀ¨í§ÒâÊýÄ¿µÄÖµ£¬ÓöººÅÍÑÀë¡£
IN ÔËËã·ûͨ³£±È OR ÔËËã·û¸üÓÐÓã¬ÓÈÆäÊÇÔÚÁбíÖаüÀ¨¶à¸öֵʱ¡£
ÈôÊÇ IN ÁбíΪ¿Õ£¬Ôò±í´ïʽʼÖÕΪ¼Ù¡£
ÒÔÉϾÍÊÇmysqlÖÐinµÄÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡