[LeetCode] 1965. Employees With Missing Information
2022. 6. 16. 00:52ㆍSQL
SELECT employee_id
FROM (SELECT e.employee_id
FROM employees AS e
LEFT JOIN salaries AS s
ON e.employee_id = s.employee_id
WHERE s.salary IS NULL
UNION
SELECT s.employee_id
FROM employees AS e
RIGHT JOIN salaries AS s
ON e.employee_id = s.employee_id
WHERE e.name IS NULL)sub
ORDER BY 1
- OUTER JOIN : FULL OUTER JOIN , LEFT OUTER JOIN, RIGHT OUTER JOIN
- FULL OUTER JOIN
=
LEFT JOIN
UNION
RIGHT JOIN
- UNION 을 할때는 컬럼의 수가 같아야 함
'SQL' 카테고리의 다른 글
[leetcode] 196. Delete Duplicate Emails (0) | 2022.10.25 |
---|---|
[LeetCode] 627. Swap Salary (0) | 2022.10.25 |
[LeetCode] 626. Exchange Seats (0) | 2022.06.09 |
[LeetCode] 180. Consecutive Numbers (0) | 2022.06.09 |
[LeetCode] 1050. Actors and Directors Who Cooperated At Least Three Times (0) | 2022.06.09 |