本文介绍了MySQL不选择空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询:
SELECT * FROM table
WHERE orderdate >= "2015-12-01"
AND orderdate <= "2015-12-31"
AND values > 0
AND orders <> 'Returned'
问题在于查询不会返回订单列为NULL的行,我无法弄清原因.
The problem is that the query doesn't return the rows where the orders column is NULL and I can't figure out why.
推荐答案
这是sql语言. Mysql不会将NULL视为值.因此,如果要包含NULL,则必须指定它.
This is the sql language. Mysql doesn't consider NULL as value. So if you want to include NULL we must specify that.
SELECT * FROM table
WHERE orderdate >= "2015-12-01"
AND orderdate <= "2015-12-31"
AND values > 0
AND (orders <> 'Returned' or orders is null)
这篇关于MySQL不选择空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!