postgresql在此查询中的子句在哪里工作?

发布于 2025-01-23 04:19:14 字数 212 浏览 0 评论 0原文

有人可以解释一下此查询中的子句如何工作吗?

    SELECT * FROM "User" AS U
    WHERE ((U."ID", U."age") > (23820, 25));

据我了解,Postgres返回了ID大于23820并忽略年龄列的用户。

Can someone explain how this WHERE clause work in this query?

    SELECT * FROM "User" AS U
    WHERE ((U."ID", U."age") > (23820, 25));

As I understand Postgres returns users where the id is greater than 23820 and ignore the age column.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倚栏听风 2025-01-30 04:19:14

@jonasmetzler在评论上是正确的。 Postgres显然将此集合用作:

Most left parameter uses the operator, all the others use equal
OR
 repeat until one parameter left (
     Remove most left parameter + 
     Most left parameter uses the operator, all the others use equal 
  )
(parameter_n, [parameter_n-1, ..., parameter_n-final]) <operator> (value_n, [value_n-1, ..., value_n-final])

equals to

(parameter_n = value_n AND parameter_n-1 = value_n-1 AND ... parameter_n-final <operator> value_n-final)
OR 
(parameter_n = value_n AND parameter_n-1 = value_n-1 AND ... parameter_n-final-1 <operator> value_n-final-1)
OR 
...
(parameter_n = value_n AND parameter_n-1 <operator> value_n-1)
OR 
(parameter_n <operator> value_n)

@JonasMetzler is correct on the comment. Postgres apparently uses this set as something on the lines of:

Most left parameter uses the operator, all the others use equal
OR
 repeat until one parameter left (
     Remove most left parameter + 
     Most left parameter uses the operator, all the others use equal 
  )
(parameter_n, [parameter_n-1, ..., parameter_n-final]) <operator> (value_n, [value_n-1, ..., value_n-final])

equals to

(parameter_n = value_n AND parameter_n-1 = value_n-1 AND ... parameter_n-final <operator> value_n-final)
OR 
(parameter_n = value_n AND parameter_n-1 = value_n-1 AND ... parameter_n-final-1 <operator> value_n-final-1)
OR 
...
(parameter_n = value_n AND parameter_n-1 <operator> value_n-1)
OR 
(parameter_n <operator> value_n)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文