select salaries.*, dept_manager.dept_no from
salaries,dept_manager on salaries.emp_no = dept_manager.emp_no
where salaries.to_date='9999-01-01'and dept_manager.to_date='9999-01-01';
查詢所有已經分配部門的員工的last_name和first_name以及dept_no
select employees.last_name,employees.first_name,dept_emp.dept_no
from employees
join dept_emp on dept_emp.emp_no = employees.emp_no;
-- left join 左連線select employees.last_name,employees.first_name,dept_emp.dept_no
from employees
leftjoin dept_emp on dept_emp.emp_no = employees.emp_no;
select dept_manager.dept_no,dept_manager.emp_no,salaries.salary
from dept_manager
leftjoin salaries on dept_manager.emp_no = salaries.emp_no
where salaries.to_date ='9999-01-01'and dept_manager.to_date ='9999-01-01'
獲取所有非manager的員工emp_no
select emp_no from employees
where emp_no notin(select emp_no from dept_manager)