当我使用上面的子句运行查询时,我得到了不同的结果,但无法理解为什么。任何人都可以解释两个条款之间的区别。在db2的where子句中,“column is null”和“column = null”之间的区别?
4
A
回答
8
column = null
的结果未知(null),因为无法知道null
究竟是什么。如果你想测试null并得到一个布尔值,你需要使用is null
。因此,`column` is null
是使用正确的语法。
5
与null的比较总是计算为false,因此column = null
的计算结果为false以及column != null
,与列的值无关。如果你想实际检查一个值是否为空,你必须使用column is null
。
相关问题
- 1. mysql查询中的“column is not null”和“column!=''”和'column <>'''有什么区别?
- 2. Breeze谓词:column = null vs column IS NULL
- 3. <column> IS NULL vs <column> =在LINQ to SQL生成SQL中的NULL
- 4. 如何让SQL识别WHERE column = NULL?
- 5. MySQL中的“!= NULL”和“IS NOT NULL”之间是否有区别?
- 6. 在Django中,如何过滤where column column =“null”?
- 7. PHP中NULL和null之间的区别
- 8. column not null deferredrable
- 9. “x IS NULL”和“NOT(x IS NOT NULL)”之间的区别是什么?
- 10. null == x和x == null之间的区别?
- 11. MySQL select where column is falsey
- 12. select count(*)and count(*)where column is not null in single query
- 13. 如何从db获取记录where column =? OR IS NULL
- 14. LINQ order by null column where order is up and nulls should last
- 15. Rails,shoulda和rspec,Column Not Null
- 16. != null和!== null之间有什么区别?
- 17. NULL WHERE子句
- 18. SQL where子句不区分' - '和NULL
- 19. 如何在IS NULL的WHERE子句中使用CASE语句?
- 20. YAML中nil和null之间的区别
- 21. MySQL之间的区别是NOT NULL和!= ''
- 22. PostgreSQL中“DROP COLUMN”和“DROP”关键字之间的区别
- 23. 如何在Mongo中“(WHERE)column = column”?
- 24. 插入列如果column = NULL
- 25. 更新与NULL和''之间的区别?
- 26. SQL - where子句NULL
- 27. DML中的NULL和NULL(“”)之间的区别
- 28. connection.close()和connection之间的区别= null
- 29. 在MySql中有什么区别!= NULL和IS NOT NULL
- 30. IS NULL在SQL的WHERE子句中不起作用
这意味着,如果条件是column = null,我将总是得到0行 – GuruKulki
@GuruKulki,那是对的。因为数据库引擎不能确定“column = null”,所以如果你选择一行作为条件,它就不能选择任何东西。而引擎可以确定'column IS NULL'是否可以返回条件为真的行。 – Paulpro