且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL server NULL值问题

更新时间:2023-01-28 18:10:26

请参阅:Common错误(关于NULL使用) [ ^ ]。


Sumon562写道:
Sumon562 wrote:

(...)必须显示一行在上面的查询的基础上。

当我更改条件 MT.TranStatus为空然后显示一行。

(...) one row has to be shown on the basis of above query.
When I change the condition MT.TranStatus is null then the one row shows.





尝试以这种方式更改代码:



Try to change code this way:

where (MT.TraApprvBy is null) and (TraApprvDate is null) and COALESCE(MT.TranStatus,'') <> 'Cancel'





COALESCE [ ^ ]函数用 NULL c>'default' value;)



COALESCE[^] function replaces NULL with 'default' value ;)


MT.TranStatus是NULL所以它不检查该行。如果你只是用其他东西编辑行,它将你必须在MT.TranStatus上插入任何状态而不是NULL
MT.TranStatus is NULL so it dont check for that row.If you simply edit the row with something else it will come.You have to insert any status on MT.TranStatus instead of NULL