一张客户表 cusotmer
一张部门表 dept
一张成绩表 score
- 查询没成绩的客户
select customer.*
left join score on customer.id = score.custormer_id
where score.score is null
- 有部门但没成绩的客户
select customer.*
left join score on customer.id = score.custormer_id
left join dept on dept.id = customer.dept_id
where score.score is null
and dept.dept_id is not null