gpt4 book ai didi

postgresql - 关键字USING在PostgreSQL中如何工作?

转载 作者:行者123 更新时间:2023-12-03 15:22:36 24 4
gpt4 key购买 nike

我对USING关键字感到困惑,该关键字用于连接postgres中的两个表。我首先在另一个post Compare two tables in postgres中看到了它。我检查了手册中的postgres 2.6. Joins Between Tables
我不明白postgres如何识别要加入的user_id(在SO帖子中)

最佳答案

PostgreSQL documentation所述:

The USING clause is a shorthand that allows you to take advantage of the specific situation where both sides of the join use the same name for the joining column(s). It takes a comma-separated list of the shared column names and forms a join condition that includes an equality comparison for each one. For example, joining T1 and T2 with USING (a, b) produces the join condition ON T1.a = T2.a AND T1.b = T2.b.



简而言之,在这种情况下,两个表都具有 user_id列,并基于它们进行联接。

关于postgresql - 关键字USING在PostgreSQL中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30476377/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com