题目如图所示:
我开始写的SQL是:=null
select * from
(
select e.name,b.bonus from Employee e left join Bonus b on e.empId = b.empId
) a where a.bonus < 1000 or a.bonus = null
或者是=‘null’
select * from
(
select e.name,b.bonus from Employee e left join Bonus b on e.empId = b.empId
) a where a.bonus < 1000 or a.bonus = ‘null’
运行结果为:
也就是说bonus为null并没有查出来。
SQL语句改为 is null
select * from
(
select e.name,b.bonus from Employee e left join Bonus b on e.empId = b.empId
) a where a.bonus < 1000 or a.bonus is null
后,执行结果为
有些不明白is null和=null的区别在哪。。。。