common rows intersection of table - Kdb+ / qStudio

Home Forums Kdb+ / qStudio common rows intersection of table

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #219

    Ash
    Guest

    What join would I use to find the common rows for two tables?
    The tables have the exact same columns, table1 will usually be a subset of table2 but I want to check just those rows that overlap between both?

    #234

    Hi Ash,

    It’s not necessary to use joins you can simply use inter. e.g.
    `
    q)t:([] a:til 10; b:10*til 10)
    q)u:([] a:0 4 4 10 9; b:0 0 40 100 90)

    q)t
    a b
    —-
    0 0
    1 10
    2 20
    3 30
    4 40
    5 50
    6 60
    7 70
    8 80
    9 90

    q)u
    a b
    ——
    0 0
    4 0
    4 40
    10 100
    9 90

    q)t inter u
    a b
    —-
    0 0
    4 40
    9 90
    `

    – Ryan

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.