1select director -- directors who have worked with star X
2from movies
3where movie_id in
4(
5 select movie_id --All movies in which star X has acted
6 from stars_in_movies
7 where star_id = "X"
8)
1 select Title from Movie m
2 inner join (select MovieID,sum(Rating) Rate from Ratings group by movieid having count(UserID)>39 order by sum(Rating) DESC limit 20) tbl
3 on m.MovieID=tbl.MovieID
4 order by tbl.Rate desc
1select director
2 from movies inner join stars_in_movies
3 where star_id=%s and movie_id = id;
1select A.first_name
2from stars A,
3(
4select star_id
5from stars_in_movies
6where movie_id = "X"
7)B,
8(
9select star_id
10from stars_in_movies
11where movie_id = "Y"
12)C
13where A.star_id = B.star_id
14AND B.star_id = C.star_id
1 `select Title
2 from Movie m
3 JOIN
4 (select MovieID, Rating
5 from Ratings
6 order by
7 Rating)
8 as r on
9 m.MovieID = r.MovieID
10 limit 20;`
1select Title from Movie m JOIN
2(select MovieID, Rating from Ratings order by Rating DESC limit 20) as r
3on m.MovieID = r.MovieID;
1select first_name --All stars who have not acted with star X
2from stars
3where star_id not in
4(
5 select star_id --All stars who have acted with star X
6 from stars_in_movies
7 where movie_id in
8 (
9 select movie_id --All movies in which star X has acted
10 from stars_in_movies
11 where star_id = "X"
12 )
13)
1select first_name,last_name
2 from stars_in_movies inner join stars
3 where (movie_id=%s and movie_id=%y) and star_id=id;
1select Title from Movie m
2inner join (select top 20 MovieID,sum(Rating) Rate from Ratings group by movieid having count(UserID)>39 order by sum(Rating) DESC) tbl
3on m.MovieID=tbl.MovieID
4order by tbl.Rate desc
1select first_name,last_name
2 from stars_in_movies inner join stars
3 where movie_id=%s and star_id=id;