मुख्य कंटेंट तक स्किप करें

Table.Join

दी गई कुंजियों के आधार पर मेल खाने वाली दो तालिकाओं की पंक्तियों को जॉइन करता है.

Syntax

Table.Join(
table1 as table,
key1 as any,
table2 as table,
key2 as any,
optional joinKind as JoinKind.Type,
optional joinAlgorithm as JoinAlgorithm.Type,
optional keyEqualityComparers as list
) as table

Remarks

key1(table1 के लिए) और key2(table2 के लिए) द्वारा चयनित कुंजी कॉलम के मानों की समानता के आधार पर table1 की पंक्तियों को table2की पंक्तियों के साथ जोड़ता है.
डिफ़ॉल्ट रूप से, एक आंतरिक जुड़ाव किया जाता है, हालांकि जुड़ाव के प्रकार को निर्दिष्ट करने के लिए एक वैकल्पिकjoinKind शामिल किया जा सकता है. विकल्पों में शामिल हैं:

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

कुंजी कॉलम की तुलना करने का तरीका निर्दिष्ट करने के लिए keyEqualityComparers का एक वैकल्पिक सेट शामिल किया जा सकता है. यह पैरामीटर वर्तमान में केवल आंतरिक उपयोग के लिए है.

Examples

Example #1

एकल कुंजी स्‍तंभ का उपयोग करके दो तालिकाओं को जोड़ें.

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"
)

Result:

Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 1, Item = "Fishing rod", Price = 100],
[CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 2, Item = "1 lb. worms", Price = 5],
[CustomerID = 2, Name = "Jim", Phone = "987-6543", OrderID = 3, Item = "Fishing net", Price = 25],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", OrderID = 4, Item = "Fish tazer", Price = 200],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", OrderID = 5, Item = "Bandaids", Price = 2],
[CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 6, Item = "Tackle box", Price = 20]
})

Example #2

एक से ज्यादा कुंजी कॉलम का उपयोग करके, दो तालिकाओं को जोड़ें जिनमें परस्पर विरोधी नाम वाले कॉलम हैं.

let
customers = Table.FromRecords({
[TenantID = 1, CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[TenantID = 1, CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}),
orders = Table.FromRecords({
[TenantID = 1, OrderID = 1, CustomerID = 1, Name = "Fishing rod", Price = 100.0],
[TenantID = 1, OrderID = 2, CustomerID = 1, Name = "1 lb. worms", Price = 5.0],
[TenantID = 1, OrderID = 3, CustomerID = 2, Name = "Fishing net", Price = 25.0]
})
in
Table.Join(
customers,
{"TenantID", "CustomerID"},
Table.PrefixColumns(orders, "Order"),
{"Order.TenantID", "Order.CustomerID"}
)

Result:

Table.FromRecords({
[TenantID = 1, CustomerID = 1, Name = "Bob", Phone = "123-4567", Order.TenantID = 1, Order.OrderID = 1, Order.CustomerID = 1, Order.Name = "Fishing rod", Order.Price = 100],
[TenantID = 1, CustomerID = 1, Name = "Bob", Phone = "123-4567", Order.TenantID = 1, Order.OrderID = 2, Order.CustomerID = 1, Order.Name = "1 lb. worms", Order.Price = 5],
[TenantID = 1, CustomerID = 2, Name = "Jim", Phone = "987-6543", Order.TenantID = 1, Order.OrderID = 3, Order.CustomerID = 2, Order.Name = "Fishing net", Order.Price = 25]
})

Category

Table.Transformation