从mysql中选择不等于

时间:2016-02-25 19:02:09

标签: mysql

您好我正在使用PHP作为服务器端语言的Web应用程序,我试图从MySql数据库中选择值不等于“某事” 我找到了很多答案,我已经尝试了下面的所有这些选择语句但是没有用,有时它返回错误或者没有返回任何注意到该列允许Null;

我尝试了什么:

 SELECT status from Orders  WHERE status <> 'canceled';
 SELECT status from Orders  WHERE status NOT IN ('canceled','deleted')
 SELECT status from Orders WHERE status NOT LIKE 'canceled'
 SELECT status from Orders WHERE status NOT LIKE '%canceled'
 SELECT status from Orders WHERE status <> 'canceled'
 SELECT status from Orders WHERE status != 'canceled'
 SELECT status from Orders WHERE NOT status='canceled'

1 个答案:

答案 0 :(得分:2)

确保您需要检查的列的初始值不是 null ,然后您可以使用

SELECT status FROM `Orders` WHERE   status NOT IN('canceled','deleted')