Update columns with Null values(使用 Null 值更新列)
问题描述
我尝试如下更新表格:
update userloginstats set logouttime = sysdate where logouttime = null;
它没有用空值更新列.出了什么问题?
It didn't update the columns with null values. What went wrong?
推荐答案
改成
...where logouttime is null;
^^^^^^^
NULL 是一个特殊值,我们不能使用通常的 = 运算符.
NULL is a special value and we cannot use the usual = operator with it.
来自 Oracle 文档 NULL:
要测试空值,仅使用比较条件 IS NULL 和 IS NOT NULL.如果您对 null 使用任何其他条件并且结果取决于 null 的值,则结果为 UNKNOWN,因为 null 表示缺少数据, null 不能 等于或不等于任何值或到另一个空
To test for nulls, use only the comparison conditions IS NULL and IS NOT NULL. If you use any other condition with nulls and the result depends on the value of the null, then the result is UNKNOWN because null represents a lack of data, a null cannot be equal or unequal to any value or to another null
这篇关于使用 Null 值更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Null 值更新列
基础教程推荐
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
