给出以下select语句:
select starttime,id
from childattendance
where endtime is null
and starttime is not null
and date < date('2018-05-24')
and companyid = 1414;
如果我将其更改为此,我会100%获得相同的结果:
select starttime,id
from childattendance
where endtime is null
and starttime >= ''
and date < date('2018-05-24')
and companyid = 1414;
在我看来,如果一个字段有一个非空值,那么它总是大于或等于一个空字符串,不是这样吗?
如果这是真的,哪个表现更好?
答案 0 :(得分:0)
这两个语句永远不能相等,因为在mysql中NULL与“”非常不同。当字段为NULL时,表示没有为该fied设置任何值。另一方面,如果字段值为“”,则表示该字段的空字符串为值。