Search code examples
azureazure-data-explorerkqlkusto-explorer

Passing multiple values in Kusto


The below first query (x) returns a column of 10 names, and then I want to run another query to find those names in another table and return the output of each row. how can I do that? I think I need something like a foreach statement:

let x = cluster('xcluster.kusto.windows.net').database('xdatabase').xtable
| limit 10
;
let y = cluster('ycluster.kusto.windows.net').database('ydatabase').ytable
| where Name has strcat("a",x)
| limit 10
;

Thank you.

Solution

  • If I understand your description correctly, you could try something like the following, which uses the has_any() function:

    let x = 
        range x from 1 to 5 step 1
        | project strcat("a", x)
    ;
    let y =
        range y from 1 to 100 step 1
        | extend y = strcat("a", y, ": something")
        | where y has_any(x)
    ;
    y
    

    This returns a table with a single column with the following string values:

    a1: something
    a2: something
    a3: something
    a4: something
    a5: something