Replace each employee id with its unique identifier when a matching record exists.
You are given two tables:
Employees(id, name)EmployeeUNI(id, unique_id)Each row in Employees represents an employee, and EmployeeUNI stores the unique identifier for some employee ids.
Return the result of listing every employee's unique_id next to their name. If an employee does not have a matching row in EmployeeUNI, the unique_id should be null.
This is equivalent to performing a left join from Employees to EmployeeUNI on id.
Employees table: columns id, nameEmployeeUNI table: columns id, unique_idEmployees.id = EmployeeUNI.idA table with columns:
unique_idnameThe rows should include every employee from Employees, using null for missing unique ids.
EmployeesExample 1
Input
Employees +----+-------+ | id | name | +----+-------+ | 1 | Alice | | 2 | Bob | | 3 | Carol | +----+-------+ EmployeeUNI +----+-----------+ | id | unique_id | +----+-----------+ | 1 | 101 | | 3 | 103 | +----+-----------+
Output
+-----------+-------+ | unique_id | name | +-----------+-------+ | 101 | Alice | | null | Bob | | 103 | Carol | +-----------+-------+
Explanation
Alice and Carol have matching rows in EmployeeUNI, while Bob does not, so Bob's unique_id is null.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.