一、查询编号>3的女神的男朋友信息,如果有则列出详细,如果没有,用null填充

  1. select b.id,b.name,bo.* from beauty b left outer join boys bo
  2. on b.boyfriend_id=bo.id
  3. where b.id>3;

二、查询哪个城市没有部门

select city from departments d right outer join locations l on d.location_id=l.location_id
where d.department_id is null;

三、查询部门名为SAL或IT的员工信息

select e.*,d.department_name,d.department_id from departments d left join employees e
on d.department_id=e.department_id
where d.department_name in ('SAL','IT');
select * from departments where department_name in ('SAL','IT');