sqlÖв»¼´ÊÇÔõôÌåÏÖ
sql ÖпÉÒÔʹÓá°¡±»ò¡°!=¡±·ûºÅÌåÏÖ²»¼´ÊÇ¡£ÕâÁ½ÖÖ·ûºÅÓÃÓÚ¼ì²é×Ö¶ÎÊÇ·ñ²»¼´ÊÇÖ¸¶¨µÄ¡°Öµ¡±¡£
SQL ÖÐÌåÏÖ²»¼´ÊÇ
ÔÚ SQL ÖУ¬²»¼´ÊÇ¿ÉÒÔʹÓá°¡±»ò¡°!=¡±·ûºÅÌåÏÖ¡£
ʹÓÃ
SELECT * FROM table_name WHERE column_name value;
µÇ¼ºó¸´ÖÆ
ʹÓà !=
SELECT * FROM table_name WHERE column_name != value;
µÇ¼ºó¸´ÖÆ
ÕâÁ½ÖÖ·ûºÅ¶¼¿ÉÒÔÓÃÀ´¼ì²é×Ö¶ÎÊÇ·ñ²»¼´ÊÇÖ¸¶¨µÄ¡°Öµ¡±¡£
ʾÀý
ÔÚÒÔÏÂʾÀýÖУ¬ÎÒÃÇʹÓá°¡±·ûºÅÅÌÎÊ¡°customers¡±±íÖС°age¡±×ֶβ»¼´ÊÇ 30 µÄËùÓмͼ£º
SELECT * FROM customers WHERE age 30;
µÇ¼ºó¸´ÖÆ
ÈôÊÇ¡°customers¡±±íÓÐÈçÏÂÊý¾Ý£º
id | name | age |
---|---|---|
1 | John | 30 |
2 | Mary | 25 |
3 | Bob | 35 |
4 | Alice | 28 |
ÄÇôÉÏÃæµÄÅÌÎʽ«·µ»ØÒÔÏÂЧ¹û£º
id | name | age |
---|---|---|
2 | Mary | 25 |
4 | Alice | 28 |
ÒÔÉϾÍÊÇsqlÖв»¼´ÊÇÔõôÌåÏÖµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£