https://leetcode.com/problems/employees-with-missing-information/
Employees With Missing Information - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
select * from (
select a.employee_id
from Employees as a
left outer join Salaries as b
on a.employee_id = b.employee_id
where b.employee_id is null
union
select b.employee_id
from Employees as a
right outer join Salaries as b
on a.employee_id = b.employee_id
where a.employee_id is null) as a
order by a.employee_id asc
best
SELECT a.employee_id
from(
SELECT employee_id from employees
union all
SELECT employee_id from salaries) as a
GROUP BY employee_id
Having count(employee_id) = 1
order by employee_id asc
References
https://gywlsp.github.io/mysql/5/
MySQL에서 테이블 inner join, outer join 하는 법
이 글은 inner join, outer join이 무엇인지, MySQL에서 join을 어떻게 사용하는지에 대해 설명한다.
gywlsp.github.io
728x90
반응형
'자료구조 알고리즘 > 코딩테스트' 카테고리의 다른 글
608. Tree Node (0) | 2022.05.30 |
---|---|
1795. Rearrange Products Table (0) | 2022.05.30 |
1527. Patients With a Condition (0) | 2022.05.30 |
1484. Group Sold Products By The Date (0) | 2022.05.30 |
1667. Fix Names in a Table (0) | 2022.05.30 |