'Leetcode 1965 finding missing information

Anybody can help me out for leetcode 1965 finding missing information. the question is as below :

Input: Employees table: +-------------+----------+ | employee_id | name | +-------------+----------+ | 2 | Crew | | 4 | Haven | | 5 | Kristian | +-------------+----------+ Salaries table: +-------------+--------+ | employee_id | salary | +-------------+--------+ | 5 | 76071 | | 1 | 22517 | | 4 | 63539 | +-------------+--------+ Output: +-------------+ | employee_id | +-------------+ | 1 | | 2 | +-------------+ Explanation: Employees 1, 2, 4, and 5 are working at this company. The name of employee 1 is missing. The salary of employee 2 is missing.

My solution is as below: I don't know what's the mistake.

select employee_id
from Employees
outer join salaries on Employees.Employee_id=salaries.Employee_id
where name is null or salary is null;

It mentioned I have an error for syntax.



Solution 1:[1]

You can try this:

select 
  employee_id
from
  Employees
where
  employee_id not in (select employee_id from Salaries)
union

select
  employee_id
from
  Salaries
where
  employee_id not in (select employee_id from Employees)
order by employee_id;

or

(SELECT 
    Employees.employee_id 
FROM 
    Employees LEFT JOIN Salaries 
ON 
    Employees.employee_id = Salaries.employee_id 
WHERE 
    Salaries.employee_id IS NULL 
UNION 
SELECT 
    Salaries.employee_id 
FROM 
    Salaries LEFT JOIN Employees 
ON 
    Employees.employee_id = Salaries.employee_id 
WHERE 
    Employees.employee_id IS NULL) 
ORDER BY 
    employee_id;

Solution 2:[2]

You can try this:

SELECT employee_id
FROM
( SELECT employee_id FROM employee
UNION ALL 
SELECT employee_id FROM salaries
)emp
GROUP BY employee_id
HAVING COUNT(employee_id)=1
ORDER BY 1;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P
Solution 2 Golam Rabbani