Reputation: 3
I have executed three tables in my program. They are MOVIE
, VIEWER
and RATING
. Within the MOVIE
table i have MovieID, MovieTitle,IMDB_URL
and a couple movie genres. With every MovieTitle there is a date(year only) in it.
I have to list all the movies that have been released in 1982 and sort them in alphabetical order. I DO NOT have a release date field in this. However i found out the MovieID of movies.
They are 89,214,228,414,423,440,527,629,632,638 and 674) All these MovieID were released in 1982. I came up with a code but it doesn't work.
Can somebody help me out here? What am i doing wrong?
SELECT Movietitle
FROM Movie
WHERE MovieID('89','214','228','414','423','440','527','629','632','638','674')
ORDER BY MovieTitle ASC
Upvotes: 0
Views: 1127
Reputation: 15797
missing "in"
SELECT Movietitle
FROM Movie
WHERE MovieID in
('89','214','228','414','423','440','527','629','632','638','674')
ORDER BY MovieTitle ASC
however if the year is in the movie title, you probably want to do something like
SELECT MovieTitle
FROM Movie
WHERE MovieTitle like '%(1982)'
ORDER BY MovieTitle ASC
edited to show to query by date
Upvotes: 1
Reputation: 18143
Try
SELECT Movietitle FROM Movie WHERE MovieID in ('89','214','228','414','423','440','527','629','632','638','674') ORDER BY MovieTitle ASC
Also, are you storing the IDs as strings? Seems like you should. If so, you would remove the quotes '' around the numbers.
Upvotes: 0