https://leetcode.com/problems/employees-with-missing-information/

 

 

MySQL 은 full outer join 기능을 제공하지 않는다.

따라서 left join 과 right join 을 각각 진행한 뒤, union 으로 합치는 방법으로 full outer join 을 구현한다.

MySQL 에서 NULL은 특별한 값이기 때문에, 일반적인 비교 연산자로 비교할 수 없다.

무조건 is NULL 혹은 is not NULL 을 사용하여 비교해야 한다.

 

 

select distinct(employee_id)
from (
    select e.employee_id, e.name, s.salary
    from Employees e left join Salaries s 
    on e.employee_id = s.employee_id
    union all
    select s.employee_id, e.name, s.salary
    from Employees e right join Salaries s 
    on e.employee_id = s.employee_id
) a
where name is null or salary is null 
order by employee_id

 

 


 

< English (feedback by ChatGPT) >

 

 

 

Since MySQL natively doesn't support full outer join operation, we perform left join and right join each and union both of them to implement full outer join.

(Since MySQL does not natively support the FULL OUTER JOIN operation, we implement it by performing both a LEFT JOIN and a RIGHT JOIN, and then combining the results using UNION.)

 

Null is a special value in MySQL, so it's impossible to compare using comparison operators.

(In MySQL, NULL is treated as a special value, so it cannot be compared using standard comparison operators.)

 

We must use 'is Null' or 'is not Null' to compare.

(Instead, we must use IS NULL or IS NOT NULL for comparisons.)

 

 

 

+ Recent posts