Postgresql Postgres查询问题
我不知道为什么这个结构不起作用。这是我第一次在博士后工作,希望有人能帮助我Postgresql Postgres查询问题,postgresql,Postgresql,我不知道为什么这个结构不起作用。这是我第一次在博士后工作,希望有人能帮助我 SELECT * FROM "friends" WHERE "from" = '1' OR "to" = '1' AND "status" = '1' SELECT * FROM "friends" WHERE ("from" = '1' OR "to" = '1') AND "status" = '1' 它返回所有值,其中“from”为1,“to”为1,而不是“status”为1的一个或另一个值 我希望这不会太令人
SELECT * FROM "friends" WHERE "from" = '1' OR "to" = '1' AND "status" = '1'
SELECT * FROM "friends" WHERE ("from" = '1' OR "to" = '1') AND "status" = '1'
它返回所有值,其中“from”为1,“to”为1,而不是“status”为1的一个或另一个值
我希望这不会太令人困惑
谢谢。OR运算符的优先级低于AND。因此,表达式的计算如下所示:
(
"from" = '1'
)
OR
(
"to" = '1'
AND
"status" = '1'
)
您可能想要的是: