[NOT] IN
查询支持使用闭包方式
[NOT] NULL :
查询字段是否(不)是Null
,例如:
Db::name('user')->where('name', null)
->where('email','null')
->where('name','not null')
->select();
实际生成的SQL语句为:
SELECT * FROM `think_user` WHERE `name` IS NULL AND `email` IS NULL AND `name` IS NOT NULL
如果你需要查询一个字段的值为字符串null
或者not null
,应该使用:
Db::name('user')->where('title','=', 'null')
->where('name','=', 'not null')
->select();
推荐的方式是使用whereNull
和whereNotNull
方法查询。
Db::name('user')->whereNull('name')
->whereNull('email')
->whereNotNull('name')
->select();