我刚开始学习SQL; 我创建了一张桌子.学习插入命令和插入值分为2行.但是我在第3个中插入了空值.
现在我想删除第3行,其中有2列没有值.
我正在使用以下查询:
delete employee where city=null;
Run Code Online (Sandbox Code Playgroud)
它似乎没有工作!
根据SQL 92个标准的许多逻辑运算空值像
> null
= null
and null
or null
not null
Run Code Online (Sandbox Code Playgroud)
应始终返回null(并且永远不会为真).某些DBMS(例如Oracle)严格遵循此规则,某些(MS SQL)可以具有null = null返回true的模式,而不是null.为了与(几乎)所有DBMS 一起使用SQL 92,你应该使用is null或is not null标准比较,在你的情况下
delete from employee
where city is null -- <- Standard comparison
Run Code Online (Sandbox Code Playgroud)