You have three tables in your relational database: Movie , Star , and RolePlayed
ID: 3821863 • Letter: Y
Question
You have three tables in your relational database: Movie, Star, and RolePlayed.
If the goal is to retrieve the title and rating of each movie in which “Meg Ryan” played a role, what errors, if any, exist in the following SQL statement?
SELECT *
FROM RolePlayed
WHERE StarID=”Meg Ryan”;
Answer:
(1) Movie (2) Star Rating Stari Name Movie Title Year Birth M1 PG-13 St1 Tom Hanks 1956 Castaway St2 Meg Ran M2 You've Got Mail PG 1961 M3 City of Angels PG-13 ISt3 Nicolas Cage 1964 (3) RolePlayed MoyielD StarD characterName M1 St1 Chuck Noland St1 M2 Joe Fox M2 St2 Kathleen Kelly M3 St2 Maggie Rice IM3 S3 SethExplanation / Answer
You query is incorrect. starID is not taking name string and you want to extract title and rating only not all the attributs using select *.Morever the rating is in another table.You have to do the join operation to get the answer.
This is a generalize query(mysql syntax), syntax varies from vendor version of sql like oracle, sql and sql server.
SELECT m.Title,m.Rating
FROM Movie m,RolePlayed r,Star s
WHERE s.StarId=r.StarID AND s.Name="Meg Ryan" AND r.MovieID=m.MovieID
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.