I'm using the IMDB database and i'm stuck with the following problem:
Get all the series of a specific movie (with it's previous part):
If you take a look at the movies table below you can see that some records have a previous_part. It's referencing to the movieId of the same table.
For example: how can i fetch the lord of the rings movies which has a previous part and also fetch that previous_part etc..
What i have so far is this:
;with SequenceChilds AS
(
SELECT movie_id, previous_part, title
FROM Movie
WHERE movie_id = 194502
UNION ALL
SELECT m.movie_id, m.previous_part, m.title
FROM Movie m
inner JOIN SequenceChilds p ON p.previous_part = m.movie_id
)
select * from SequenceChilds
This is giving me the following result:
It seems like it isn't iterating deeply enough, because what i expect from the result is to give back the following:
Much appreciated if someone can point me to the right direction. Thanks in advance!