sqlÖв»¼´ÊÇij¸öÌõ¼þÔõôд³öÀ´µÄ
sql Öв»¼´ÊÇij¸öÌõ¼þ¿ÉʹÓà not condition¡£ÀýÈ磺²»¼´ÊÇij¸öÖµ£ºwhere column_name value£»²»¼´ÊÇÁбíÖеÄÖµ£ºwhere column_name not in (list)£»²»¼´ÊÇ×ÓÅÌÎÊЧ¹û£ºwhere column_name (subquery)¡£
SQL Öв»¼´ÊÇij¸öÌõ¼þµÄд·¨
ÔÚ SQL ÖУ¬²»¼´ÊÇij¸öÌõ¼þ¿ÉÒÔʹÓÃÒÔÏÂÓï·¨£º
NOT condition
µÇ¼ºó¸´ÖÆ
ÆäÖÐ condition ÊÇÐèҪȡ·´µÄÌõ¼þ¡£
ʾÀý 1£º²»¼´ÊÇij¸öÖµ
ÀýÈ磬ҪÅÌÎʲ»¼´ÊÇ 10 µÄËùÓмͼ£¬¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º
SELECT * FROM table_name WHERE column_name 10;
µÇ¼ºó¸´ÖÆ
ʾÀý 2£º²»¼´ÊÇij¸öÁбíÖеÄÖµ
ÒªÅÌÎʲ»¼´ÊÇ (10, 20, 30) µÄËùÓмͼ£¬¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º
SELECT * FROM table_name WHERE column_name NOT IN (10, 20, 30);
µÇ¼ºó¸´ÖÆ
ʾÀý 3£º²»¼´ÊÇij¸ö×ÓÅÌÎÊ
ÒªÅÌÎʲ»¼´ÊÇ×ÓÅÌÎÊ·µ»ØЧ¹ûÖеÄËùÓмͼ£¬¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º
SELECT * FROM table_name WHERE column_name (SELECT column_name FROM other_table_name WHERE condition);
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇsqlÖв»¼´ÊÇij¸öÌõ¼þÔõôд³öÀ´µÄµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£