Search code examples
joinkdb

kdb - lj 3 tables on key column


is anyone able to tell me if there is an efficient way to left join 3 tables on orderID column? for uj I tried the following which is fine: () uj/(a;b;c) but can we do similar for a lj with xkey over orderID col?


Solution

  • yes this is possible, the syntax is

    q)t1:([id:1 2 3] name:`a`b`c)
    q)t2:([id:1 2 3] address:4 5 6)
    q)t3:([id:1 2 3 4] age:10 11 12 14)
    q)(lj/)(t1;t2;t3)
    id| name address age
    --| ----------------
    1 | a    4       10
    2 | b    5       11
    3 | c    6       12
    

    btw the syntax for uj should be the same (uj/)(a;b;c)