mysqlÖÐandµÄÓ÷¨
mysql ÖÐ and ÔËËã·ûÅþÁ¬²¼¶û±í´ïʽ£¬µ±ÇÒ½öµ±ËùÓбí´ïʽΪÕæʱ·µ»ØÕ棬²»È»·µ»Ø¼Ù¡£ËüÓÃÓÚËõСÅÌÎÊЧ¹û£¬²éÕÒÖª×ã¶à¸öÌõ¼þµÄ¼Í¼»òɨ³ý²»ÇкÏÌõ¼þµÄ¼Í¼¡£
MySQL ÖÐ AND µÄÓ÷¨
MySQL ÖÐµÄ AND ÔËËã·ûÓÃÓÚÅþÁ¬Á½¸ö»ò¶à¸ö²¼¶û±í´ïʽ£¬ÌìÉúÒ»¸ö·µ»Ø TRUE »ò FALSE µÄЧ¹û¡£µ±ÇÒ½öµ±ËùÓÐÅþÁ¬µÄ±í´ïʽ¶¼Îª TRUE£¬Ð§¹û²ÅΪ TRUE¡£²»È»£¬Ð§¹ûΪ FALSE¡£
Óï·¨
±í´ïʽ1 AND ±í´ïʽ2 ...
µÇ¼ºó¸´ÖÆ
ʾÀý
SELECT * FROM users WHERE age > 18 AND gender = 'male';
µÇ¼ºó¸´ÖÆ
´ËÅÌÎʽ«¼ìË÷ËùÓÐÄêËê´óÓÚ 18 ËêÇÒÐÔ±ðΪÄÐÐÔµÄÓû§¼Í¼¡£
ÓÅÏȼ¶
AND ÔËËã·ûµÄÓÅÏȼ¶µÍÓÚ OR ÔËËã·û£¬¸ßÓÚ NOT ÔËËã·û¡£
ÕæÖµ±í
±í´ïʽ 1 | ±í´ïʽ 2 | Ч¹û |
---|---|---|
TRUE | TRUE | TRUE |
TRUE | FALSE | FALSE |
FALSE | TRUE | FALSE |
FALSE | FALSE | FALSE |
ʹÓó¡¾°
AND ÔËËã·ûͨ³£ÓÃÓÚËõСÅÌÎÊЧ¹û¡£ÀýÈ磺
²éÕÒÖª×ã¶à¸öÌõ¼þµÄ¼Í¼¡£
ÅþÁ¬¶à¸ö²¼¶û±í´ïʽÒÔ½¨Éè¸üÖØ´óµÄÅÌÎÊ¡£
ɨ³ý²»ÇкÏÌض¨Ìõ¼þµÄ¼Í¼¡£
×¢ÖØÊÂÏî
×èÖ¹ÔÚ±í´ïʽÖÐʹÓà AND NULL£¬ÓÉÓÚËüʼÖÕ·µ»Ø NULL¡£
¿ÉÒÔ½«¶à¸ö AND ÔËËã·û×éºÏÔÚÒ»ÆðÒÔ½¨Éè¸üÖØ´óµÄÌõ¼þ¡£
ʹÓÃÀ¨ºÅÀ´¿ØÖÆÔËËã·ûµÄÓÅÏȼ¶¡£
ÒÔÉϾÍÊÇmysqlÖÐandµÄÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡