MySQL如何正确查询字段为NULL的字段

时间:2024-03-12 19:21:19

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

$tk_Ids = M("LsnSelected")->where("use_tool=8 AND tk_roomId is null")->select();        (正确)

$tk_Ids = M("LsnSelected")->where("use_tool=8 AND tk_roomId=NULL")->select();      (错误)

==========================================================================================================

说明:

1、查询字段值为空的语法:where <字段名> is null
2、查询字段值不为空的语法:where <字段名> is not null

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++