Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 need sql help

Author  Topic 

taiL
Starting Member

1 Post

Posted - 2009-10-11 : 20:39:24
I need help understanding why this syntax does not work.

I am given 3 tables where one references to the other two (in my case actors, movies, casting).

So if I want to find the cast of a movie I try this


SELECT name
FROM ACTOR A, MOVIE M, CASTING C
WHERE MOVIE.title LIKE 'SO and SO'
M.id = Casting.movieid
A.id = C.actorid


But when I try and run it it says that

quote:

FROM ACTOR A, MOVIE M, CASTING C
*
ERROR at line 2:



Am I using the "Actor A, Movie M, Casting C" wrong

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-11 : 22:01:44


SELECT name
FROM ACTOR A, MOVIE M, CASTING C
WHERE MOVIE M.title LIKE 'SO and SO'
AND M.id = Casting C.movieid
AND A.id = C.actorid


should use ANSI JOIN method


SELECT name
FROM ACTOR A
INNER JOIN CASTING C ON A.id = C.movieid
INNER JOIN MOVIE M ON M.id = C.actorid
WHERE M.title LIKE 'SO and SO'





KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jason97m
Starting Member

4 Posts

Posted - 2009-10-12 : 04:01:13
Just for the sake of clarity, can you tell me what your foreign keys are that link together the tables?

Jason Morris
BRIXTON.US
Go to Top of Page
   

- Advertisement -