자료구조 알고리즘/코딩테스트

1965. Employees With Missing Information

내공얌냠 2022. 5. 30. 21:31

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
반응형