Table.JoinTable.Join

SintaxeSyntax

Table.Join(table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as nullable number, optional joinAlgorithm as nullable number, optional keyEqualityComparers as nullable list) as table

SobreAbout

Une as linhas de table1 com as linhas de table2 com base na igualdade dos valores das colunas de chave selecionadas por key1 (para table1) e key2 (para table2).Joins the rows of table1 with the rows of table2 based on the equality of the values of the key columns selected by key1 (for table1) and key2 (for table2).

Por padrão, uma junção interna é executada, no entanto, um joinKind opcional pode ser incluído para especificar o tipo de junção.By default, an inner join is performed, however an optional joinKind may be included to specify the type of join. As opções incluem:Options include:

  • JoinKind.Inner
  • JoinKind.LeftOuter
  • JoinKind.RightOuter
  • JoinKind.FullOuter
  • JoinKind.LeftAnti
  • JoinKind.RightAnti

Um conjunto opcional de keyEqualityComparers pode ser incluído para especificar como comparar as colunas de chave.An optional set of keyEqualityComparers may be included to specify how to compare the key columns. Atualmente, esse recurso é destinado somente para uso interno.This feature is currently intended for internal use only.

Exemplo 1Example 1

Junção interna das duas tabelas em [CustomerID]Inner join the two tables on [CustomerID]

Table.Join(
    Table.FromRecords({
        [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
        [CustomerID = 2, Name = "Jim", Phone = "987-6543"],
        [CustomerID = 3, Name = "Paul", Phone = "543-7890"],
        [CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
    }),
    "CustomerID",
    Table.FromRecords({
        [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
        [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
        [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
        [OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
        [OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
        [OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
        [OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25]
    }),
    "CustomerID"
)
CustomerIDCustomerID NomeName TelefonePhone OrderIDOrderID ItemItem PreçoPrice
11 RobertoBob 123-4567123-4567 11 Vara de pescarFishing rod 100100
11 RobertoBob 123-4567123-4567 22 1 lb de minhocas1 lb. worms 55
22 JimJim 987-6543987-6543 33 Rede de pescaFishing net 2525
33 PaulPaul 543-7890543-7890 44 Taser de peixeFish tazer 200200
33 PaulPaul 543-7890543-7890 55 BandaidsBandaids 22
11 RobertoBob 123-4567123-4567 66 Caixa de material de pescaTackle box 2020