SQL 문제풀이
leetcode - 1378. Replace Employee ID With The Unique Identifier
Jerrytwo
2022. 7. 8. 16:25
난이도 : Easy
Table: Employees
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| id | int |
| name | varchar |
+---------------+---------+
id is the primary key for this table.
Each row of this table contains the id and the name of an employee in a company.
Table: EmployeeUNI
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| id | int |
| unique_id | int |
+---------------+---------+
(id, unique_id) is the primary key for this table.
Each row of this table contains the id and the corresponding unique id of an employee in the company.
Write an SQL query to show the unique ID of each user, If a user does not have a unique ID replace just show null.
Return the result table in any order.
SELECT IFNULL(unique_id, null) unique_id
, name
FROM Employees
LEFT JOIN EmployeeUNI ON EmployeeUNI.id = Employees.id
Accepted (36.42%)