0

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
Taryn
  • 242,637
  • 56
  • 362
  • 405
Chirag P
  • 3
  • 1

2 Answers2

1

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

MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89
  • It's a wildcard. So that statement matches anything that ends with (1982). If you use '%(1982)%' it would find anything that has (1982) in it... and '(1982)%' would mean "starts with" – MikeSmithDev Nov 10 '12 at 23:17
0

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.

Marvo
  • 17,845
  • 8
  • 50
  • 74
  • 1
    Yes i am. But '%(1982)' looks better so im going to go ahead and use that. Thanks for the help though – Chirag P Nov 10 '12 at 23:16
  • I agree that that's the better solution. Even better would be to use some sort of API to IMDB, but from the looks of this question, there isn't one. http://stackoverflow.com/questions/100280/connecting-to-imdb – Marvo Nov 11 '12 at 00:33