KDB如何连接具有不同列名的表

KDB How to join tables with different column names

如果我有下表:

  t1:([] c1: 1 2 3; c2: 120 234 876)
  t2:([] cd1:1 2; d: 999 899)

如何连接表 t1.c1 = t2.cd2,其中 c1cd2 不是链接列?

您希望按如下方式使用左联接 lj

q)t1: ([] c1: 1 2 3; c2: 120 234 876)
q)t2:([] cd1:1 2; d: 999 899)
q)t1 lj 1!`c1 xcol t2
c1 c2  d
----------
1  120 999
2  234 899
3  876

我们使用 xcol 重命名 t2 中的列 cd1 以匹配 t1 中的 c1

您可以在 https://code.kx.com/q/ref/joins/

阅读有关联接的更多信息