题目链接:https://sqlzoo.net/wiki/More_JOIN_operations
SELECT id, title FROM movie
WHERE yr=1962
select yr from movie
where title='Citizen Kane';
select id,title,yr from movie
where title like'%Star Trek%'
order by yr;
select id from actor
where name='Glenn Close';
select id from movie
where title='Casablanca';
select name from actor
join casting on id=actorid
where movieid=11768;
select name from actor a
join (casting b,movie c)
on a.id=b.actorid and b.movieid=c.id
where c.title='Alien';
select title from movie a
join (actor b,casting c) on a.id=c.movieid and c.actorid=b.id
where b.name='Harrison Ford';
select title from movie a
join (actor b,casting c)
on a.id=c.movieid and c.actorid=b.id
where b.name='Harrison Ford' and c.ord !=1;
select a.title,b.name from movie a
join (actor b,casting c)
on a.id=c.movieid and b.id=c.actorid
where yr='1962' and c.ord=1;
SELECT yr,COUNT(title) FROM movie a
JOIN (casting b,actor c)ON a.id=b.movieid and b.actorid=c.id
where name='John Travolta'
GROUP BY yr
HAVING COUNT(title)=(SELECT MAX(count) FROM
(SELECT yr,COUNT(title) count FROM
movie a JOIN (casting b,actor c) ON a.id=b.movieid and b.actorid=c.id
where name='John Travolta'
GROUP BY yr) t)
select a.title,b.name from movie a
join (actor b,casting c) on a.id=c.movieid and b.id=c.actorid
where movieid in
(
select a.id from movie a
join (casting b,actor c) on a.id=b.movieid and c.id = b.actorid
where c.name='Julie Andrews')
and c.ord =1;
select name from actor a
join (casting b,movie c) on a.id=b.actorid and c.id=b.movieid
where ord=1
group by name
having count(name)>=30;
select title,count(actorid)
from movie a join (casting b,actor c) on a.id=b.movieid and c.id=b.actorid
where yr=1978
group by title
order by count(actorid)desc,title;
select a.name from actor a
join (movie b,casting c) on a.id=c.actorid and b.id=c.movieid
where a.name !='Art Garfunkel'
and b.id IN
(select a.id from movie a
join (actor b,casting c) on a.id=c.movieid and b.id=c.actorid
where b.name='Art Garfunkel')