mysqlÖÐwhereµÄ×÷ÓÃ
where ×Ó¾äÓÃÓÚƾ֤Ìõ¼þ¹ýÂË mysql ÅÌÎÊЧ¹û£¬½«Öª×ãÌõ¼þµÄÐаüÀ¨ÔÚЧ¹ûÖС£Ëüͨ¹ýÖ¸¶¨±í´ïʽ¾ÙÐÐÌõ¼þɸѡ£¬ÀýÈçÖµ½ÏÁ¿¡¢¹æÄ£½ÏÁ¿»òÂß¼ÔËË㣬֧³ÖÖØ´óÅÌÎʺÍÌض¨Ãü¾ÝµÄ»ñÈ¡¡£
MySQL ÖÐ WHERE ×Ó¾äµÄ×÷ÓÃ
WHERE ×Ó¾äÊÇ MySQL ÅÌÎÊÓï¾äÖÐÓÃÓÚ¹ýÂË·µ»ØЧ¹ûµÄÒ»ÏîÇ¿Ê¢¹¤¾ß¡£ËüÔÊÐíÄúÖ¸¶¨Òª°üÀ¨ÔÚÅÌÎÊЧ¹ûÖеÄÌض¨ÐС£
×÷ÓÃ
WHERE ×Ó¾äµÄÖ÷Òª×÷ÓÃÊÇƾָ֤¶¨Ìõ¼þ´Ó±íÖÐɸѡÊý¾Ý¡£
Óï·¨
SELECT column_list FROM table_name WHERE condition;
µÇ¼ºó¸´ÖÆ
ÆäÖУº
condition ÊÇÓÃÓÚ¹ýÂËÐеıí´ïʽ¡£
condition ¿ÉÒÔÊÇ£º
Öµ½ÏÁ¿£¨Èç column_name = value£©
¹æÄ£½ÏÁ¿£¨Èç column_name BETWEEN value1 AND value2£©
Âß¼ÔËËã·û£¨Èç AND¡¢OR¡¢NOT£©
×ÓÅÌÎÊ
Ó÷¨
WHERE ×Ó¾äͨ³£ÓÃÓÚ£º
ƾ֤Ìض¨Ìõ¼þ»ñÈ¡Ìض¨Ãü¾Ý£¨Èç»ñÈ¡¶©µ¥ºÅΪ 1001 µÄËùÓж©µ¥£©
ɨ³ý²»ÇкÏÌõ¼þµÄÐУ¨Èçɨ³ýÒÑ×÷·ÏµÄ¶©µ¥£©
×éºÏ¶à¸öÌõ¼þÒÔ½øÒ»²½Ï¸»¯Ð§¹û£¨Èç»ñÈ¡¶©µ¥ºÅ´óÓÚ 1000 ÇÒ¶©µ¥×´Ì¬Îª “ÒÑ´¦Àí” µÄ¶©µ¥£©
ʾÀý
-- »ñÈ¡ËùÖøÃûΪ "John" µÄ¿Í»§ SELECT * FROM customers WHERE name = "John";
µÇ¼ºó¸´ÖÆ
-- »ñÈ¡¶©µ¥×ܶî´óÓÚ 500 µÄËùÓж©µ¥ SELECT * FROM orders WHERE total_amount > 500;
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏî
WHERE ×Ó¾äÖ»ÄÜÓÃÓÚ SELECT Óï¾ä¡£
ÈôÊDz»Ê¹Óà WHERE ×Ӿ䣬ÔòÅÌÎʽ«·µ»Ø±íÖеÄËùÓÐÐС£
WHERE ×Ó¾äÖеÄÌõ¼þ±ØÐèΪ²¼¶ûÖµ£¨Õæ»ò¼Ù£©¡£
WHERE ×Ó¾äÖеÄÌõ¼þ¿ÉÒÔÒýÓñíÖеÄÁС¢º¯Êý»ò×ÓÅÌÎÊ¡£
ÒÔÉϾÍÊÇmysqlÖÐwhereµÄ×÷ÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡