很好的发现,我也找不到关于它的文档,但我做了进一步的实验,发现了一些有趣的行为。
with t1 as (
select 1 as a
, 2 as b
, 3 as c
)
, t2 as (
select 1 as a
, 5 as b
, 6 as c
)
SELECT
*
FROM
t1
INNER JOIN
t2
USING(a, b, c);
为所有人生成匹配项
但是当您操作代码时,USING(a. b, c)
它会将 A 放在末尾,并且该列出现两次!
当我更改列中的值并将点保持在输出的位置时......什么都没有
with t1 as (
select 1 as a
, 2 as b
, 3 as c
)
, t2 as (
select 1 as a
, 5 as b
, 6 as c
)
SELECT
*
FROM
t1
INNER JOIN
t2
USING(a. b, c);
现在再改一下
with t1 as (
select 1 as a
, 2 as b
, 3 as c
)
, t2 as (
select 4 as a
, 2 as b
, 3 as c
)
SELECT
*
FROM
t1
INNER JOIN
t2
USING(a. b, c);
B 和 C 应该匹配但 A 不匹配 非匹配列出现两次
开始在这里看到一个模式吧?
似乎在连接中使用了没有点的列,但另一列没有。似乎您只能使用带有点表示法的一列,添加更多点列会出错。