我想让所有人都有一个空字段。
我尝试了以下操作,但未返回任何内容。
$plato = $this->Platos->find('all',[
'conditions' => ['alergia_id' => null]
]);
在SQL中,
null
不等于(=)
-甚至不等于另一个null
。根据SQL的三值逻辑,结果null = null
不是正确的,但未知。 SQL具有is [not] null
谓词测试特定值是否为null。
https://modern-sql.com/feature/is-distinct-from
这是解决方案。
$plato = $this->Platos->find('all',[
'conditions' => ['alergia_id IS null']
]);