Left Join
MediumData EngineeringArraySortingSQL
Description
Given a left table and a right table as arrays of [key, value] pairs (keys unique within each), return the left join: every left row as [key, leftValue, rightValue], using null for the right value when the key is missing on the right. Preserve left order.
Examples
Input:
[[1,10],[2,20],[3,30]], [[2,200],[3,300]]Output:
[[1,10,null],[2,20,200],[3,30,300]]Explanation:
Every left row is kept and matched with its right value when the key exists, otherwise the right side is left empty.
Input:
[[1,5]], [[1,50]]Output:
[[1,5,50]]Explanation:
Every left row is kept and matched with its right value when the key exists, otherwise the right side is left empty.
Input:
[[1,1],[2,2]], [[3,3]]Output:
[[1,1,null],[2,2,null]]Explanation:
Every left row is kept and matched with its right value when the key exists, otherwise the right side is left empty.
Constraints
- •
0 ≤ each table ≤ 10⁴ - •
keys unique within a table