首页 > 解决方案 > 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)) 但它不起作用。

任何帮助表示赞赏。

标签: postgresqlpostgrest

解决方案


似乎您需要像这样传递它:

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))

希望这可以解决。


推荐阅读