使用left join 连接表,使得以电影票为左边都有数据,
select t1.film_id,t1.title,t3.category_id
from film t1 left join film_category t2 on
t1.film_id = t2.film_id
left join category t3 on
t2.category_id = t3.category_id
此时没有类别的电影为第三行,t3.category_id is null过滤即可,即答案为
select t1.film_id,t1.title
from film t1 left join film_category t2 on
t1.film_id = t2.film_id
left join category t3 on
t2.category_id = t3.category_id
where t3.category_id is null