Question
create table movies ( movie_id integer, name varchar(1000), score integer ); create table cast ( movie_id integer, cast_id integer, cast_name varchar(1000) ); Using the tables
create table movies ( movie_id integer, name varchar(1000), score integer );
create table cast ( movie_id integer, cast_id integer, cast_name varchar(1000) );
Using the tables created above, find the movies with score > 80 and has no cast members with name David. Output format: movie_id, score.
insert into movies1 values(111, "Frozen", 90); insert into movies1 values(222, "Cars", 10); insert into movies1 values(333, "Finding Nemo", 100); insert into movies1 values(444, "Toy Story", 20); insert into cast1 values(111, 1, "David"); insert into cast1 values(111, 2, "Sarah"); insert into cast1 values(222, 3, "Jim"); insert into cast1 values(222, 4, "Brennan"); insert into cast1 values(333, 5, "Gary"); insert into cast1 values(333, 6, "Pat"); insert into cast1 values(444, 7, "Kim"); insert into cast1 values(444, 8, "Jim");
This is what I tried, yet it does prints out movie_id 111 and 333 when it should only print out movie_id 333 select distinct m.movie_id, m.score from movies1 m inner join cast1 c on c.movie_id = m.movie_id where m.score > 80 and c.cast_name not like "%David%";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started