3

How do i create a join query that uses two or more columns?

Im trying to do something like this but I cant find any examples on how to join on multiple columns

let logMaster = Table1 
let logClient = Table1 
logMaster
| join kind=innerunique (logClient) on ($left.field1 == $right.field1 && $left.field2 == $right.field2) 

Ive tried comma separated (which I think the documents kind of hint at, and &&, and AND, but none of them seem to work.

JensB
  • 6,663
  • 2
  • 55
  • 94

1 Answers1

6

use the "and" keyword, here is an example:

let logMaster = datatable(a:string, b:string, c:long) ["a", "b", 5, "a", "v", 10] ;
let logClient = datatable(a:string, b:string, d:long) ["a", "b", 5, "a", "y", 10] ;
logMaster
| join kind=innerunique (logClient) on $left.a == $right.a and  $left.b == $right.b

As a side note, using the "lookup" operator will likely provide you with better perf and remove the duplicate join columns

Avnera
  • 7,088
  • 9
  • 14