February 6, 2014 at 7:07 pm
Newbie here. Having trouble with a multi-table join exercise, code below. A two-table join works fine but more than that produces this error:
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'vt_exam_details'.
Every query with 3 or more tables produces this error on the second joined table. I'm running 2008R2 on Windows 7.
use a_vets;
go
SELECT
ED.ex_id,
EH.ex_date,
S.srv_id,
ED.ex_fee
FROM
vt_animals as A
INNER JOIN
vt_exam_headers as EH on (A.an_id = EH.an_id)
vt_exam_details as ED on (EH.ex_id = ED.ex_id)
vt_services as S on (ED.srv_id = S.srv_id)
WHERE
A.an_type in ('rodent')
ORDER BY
S.srv_id;
GO
February 6, 2014 at 7:29 pm
The problem is that you left out the other INNER JOIN statements:
...
FROM
vt_animals as A
INNER JOIN
vt_exam_headers as EH on A.an_id = EH.an_id
INNER JOIN
vt_exam_details as ED on EH.ex_id = ED.ex_id
INNER JOIN
vt_services as S on ED.srv_id = S.srv_id
Hope that helps.
February 6, 2014 at 7:58 pm
Well, of course I knew that. (not!) Thanks for your very timely help!
February 6, 2014 at 9:00 pm
timSF (2/6/2014)
Well, of course I knew that. (not!) Thanks for your very timely help!
Well you were close and did a fine job of posting your exact problem.
Those who answer questions on these forums appreciate that.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 7, 2014 at 5:08 pm
Yep, makes it MUCH easier to see what you were doing wrong. Way to go, young Jedi.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply