postgresql - Postgrest 查询。当 id = id 或 (user id = id and boolean = true) 时从表中选择 *
问题描述
我试图在 postgres 上的 postgres 中做一个简单的查询。
基本上这是我要重新创建的查询(ID、Other_id 和布尔值都是表中的列)
SELECT *
FROM TABLE
WHERE ID = 'ID'
OR (OTHER_ID = 'OTHER_ID' AND BOOLEAN = true);
我已经尝试了下面的 postgrest url(按照文档)
https://table?and=(id.eq.id,or(boolean.is.true,other_id.eq.other_id)) 但它不起作用。
任何帮助表示赞赏。
解决方案
似乎您需要像这样传递它:
https://table?or=(id.eq.id,and=(boolean.is.true,other_id.eq.other_id))
根据文档,语法类似于 opertaor=(operand1 , operand2) ,所以基本上你正在做或首先因为这是你正在做的
OR=(x,Y) 但 Y 是混合标准,所以 OR=(x,AND=(a,b))
希望这可以解决。
推荐阅读
- python - 如何从 Google Cloud Storage 存储桶加载保存在 joblib 文件中的模型
- javascript - React JSX 中的加法 - A + B
- batch-file - 将 IP 地址和主机名输出到配置文件
- python - 将 utf-8 写入文件但解析不正确
- reactjs - 无法使用 babel 和 react-bootstrap 与 Laravel 反应
- regex - [Regex]::Match() 在 If 内部和外部的行为不同(也使用 [Regex]::Match() )
- css - JavaFX - 根据切换状态在切换按钮上设置不同的悬停颜色
- javascript - Javascript画布绿色椭圆左侧和红色右侧
- amazon-web-services - 即使在添加凭证之后,AWS Lambda 无服务器部署也要求提供 AWS 提供商凭证
- javascript - 卡在 onclick 和 document.GetElementById