Wednesday, 25 September 2013

MS SQL Join Relational Table with a Where Clause

MS SQL Join Relational Table with a Where Clause

If I take out the WHERE clause the Join seems to work fine on glance...
and the imageID 485 does exist... however, when I insert the WHERE clause
below I come back with 0 results.
How do I add the WHERE clause to properly work with 3 tables joining?
declare @imageID int
set @imageID = 485
SELECT Image.imageID, Image.filename, Image.imageFile
FROM MovieHasImage
JOIN Movie
ON MovieHasImage.movieID = Movie.movieID
JOIN Image
ON MovieHasImage.imageID = Image.imageID
WHERE Image.imageID = @imageID --HERE IS THE CAUSE OF THE ISSUE
GO

No comments:

Post a Comment