list - Cakephp 找到空值
问题描述
我想让每个拥有空字段的人。
我尝试了以下但它没有返回任何东西。
$plato = $this->Platos->find('all',[
'conditions' => ['alergia_id' => null]
]);
解决方案
在 SQL
null
中不等于(=)
任何东西——甚至不等于另一个null
. 根据 SQL 的三值逻辑,结果null = null
不为真但未知。SQL 具有is [not] null
用于测试特定值是否为空的谓词。
https://modern-sql.com/feature/is-distinct-from
这就是解决方案。
$plato = $this->Platos->find('all',[
'conditions' => ['alergia_id IS null']
]);
推荐阅读
- r - 在 R 中用时间序列外推学习模型
- spring-boot - 使用 JwkSetUri 向 NimbusJwtDecoder 进行身份验证失败
- javascript - React 渲染和按钮点击重定向
- vb.net - 我的代码将图片框移向另一个图片框有什么问题?
- javascript - 在 Apollo v3 React 客户端 fe-retching 不同查询的情况下如何实现乐观 UI
- excel - VBA 保留从其他网页复制粘贴内容的单元格格式
- webrtc - Mac 的 Screencapturer,Webrtc 留下关闭菜单的印象
- git - 如何在不合并的情况下删除功能分支后保留对公共文件的修改?
- python - 总和小于 X 且大于 Y 的所有子数组
- python - 使用电话电子邮件和用户名验证 django 用户