SQL 50, decoded
0 of 50 solved/50

1378. Replace Employee ID With The Unique Identifier

SQL 50 · Basic Joins (day 2). Decode it with the hints, solve it on LeetCode, then compare with the reference solution in MySQLPostgreSQL.

EasySolve it on LeetCode ↗

Your work

Hints

Open one at a time. Try to finish with as few as you can.

1. What does one output row represent?
One employee, including those without a unique id.
2. Approach
LEFT JOIN EmployeeUNI ON id.
3. The trap
INNER JOIN would drop employees with no unique id.

Reference solution

Tested on MySQL 8.0 and PostgreSQL 16. Switch dialect at the top of the page.

Show the MySQLPostgreSQL solution
SELECT u.unique_id, e.name
FROM Employees e
LEFT JOIN EmployeeUNI u ON e.id = u.id;

Patterns used

Which join