项目场景:在SQL中判断条件 is null , 和TP框架条件判断 = null 所查询结果不一样
问题描述`
代码描述:
$condition[] = ['id', '=','null'];
解决方案:
在你的SQL运行语句中 新增一个 where 条件:
$condition[] = ['id', '>',10000];
$condition2 = " tast_id is null";
$list = model("user")->alias("a")->field("a.id,
a.name,
case when id is not null then 1 else 0 end as is_check")
->where($condition)->where($condition2)
->select();
直接使用原生放到第二个where 条件中,完美即简单的解决了这个问题。