當我使用此查詢:在使用時不爲空不同的結果
SELECT * from [dbo].[CRA]
where [gender] like 'null'
and [house] like 'null'
and [residenttime] is null
and [worktime] is null
and [loaiDN] like 'null'
and [depend] like 'null'
and [expGD] like 'null'
and [Grincome] like 'null'
and [dunocacTCTD] like 'null'
and [tinhtrangno] like 'null'
and [tgQHTD] like 'null'
and [soduTB] like 'null'
and [TlquaMB] like 'null'
結果:81行
但使用此查詢時:去除
SELECT * from [dbo].[CRA]
where [gender] not like 'null'
and [house] not like 'null'
and [residenttime] is not null
and [worktime] is not null
and [loaiDN] not like 'null'
and [depend] not like 'null'
and [expGD] not like 'null'
and [Grincome] not like 'null'
and [dunocacTCTD] not like 'null'
and [tinhtrangno] not like 'null'
and [tgQHTD] not like 'null'
and [soduTB] not like 'null'
and [TlquaMB] not like 'null'
行的數是> 1000行
爲什麼這兩個結果是不同的?
你知道布爾代數嗎? – GurV
爲什麼使用不帶通配符的LIKE運算符?也可以使用等於和不等於。另外'null'是一個不是NULL值的字符串。你必須使用'IS NULL'和'IS NOT NULL'來檢查NULL是否等於equals,否則equals將始終返回false。 –
它的cus只有兩個變量實際上在excel文件中沒有任何值,其他變量有「null」填充,所以我必須使用不同的命令 – QVT