Forum Discussion

Madxfr's avatar
Madxfr
Frequent Visitor
7 years ago
Solved

Create one table from 2 tables (inner join)

Hello,

 

I have 2 tables with:

 

Table1

id  Col1 Col2 Col3

1   A      BB      2

1   A      CC      4

1   B      AA      5

2   A      CC      10

2   B      AA      6

2   C      CC      8

2   A      CC      10

3   D      BA      6

3   H      FC      8

 

Table2

id  Col1 Col2 Col3

1   XX4     1      2

1   AA5     5     4

1   BB1      8     5

3   AC1      9    10

3   BD2     10    6

3   C      CC      8

 

Result expected:

Table_Res

id  Col3

1   2

1   4

1   5

3   6

3   8

 

I need to create a table with column id and Col3 from Table1 but only where id included in table2.

A kinf of : select id,col3 from table1 inner join table2 on table1.id=table2.id

 

Thanks for your help.

 

 

  • Anonymous's avatar
    Anonymous
    7 years ago

    HI Madxfr ,

    You can use values function to extract table 2 id and use 'in' operator to compare with these fields:

    NEW Table =
    SELECTCOLUMNS (
        FILTER ( Table1, [id] IN VALUES ( Table2[id] ) ),
        "id", [id],
        "Col3", [Col3]
    )

    Regards,

    Xiaoxin Sheng

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Madxfr ,

    You can use values function to extract table 2 id and use 'in' operator to compare with these fields:

    NEW Table =
    SELECTCOLUMNS (
        FILTER ( Table1, [id] IN VALUES ( Table2[id] ) ),
        "id", [id],
        "Col3", [Col3]
    )

    Regards,

    Xiaoxin Sheng

    • Madxfr's avatar
      Madxfr
      Frequent Visitor

      Thanks, it's faster than merge table and so simple when you have the solution ;-)