I have 4 tables (connected by foreing keys) :A,B,C,D and i have to query table D by attributes of tables A,D,C,D.
In previous application i did the same task on tables A,B (get all B elements by attributes of A,B) I used the following query (that worked right ):
SELECT DISTINCT B.* FROM B LEFT JOIN A ON B.key = A.foreing key WHERE ..."
Now I try to perform the same with 4 tables:
SELECT DISTINCT D.* FROM D LEFT JOIN C LEFT JOIN B LEFT JOIN A ON D.key=C.foreing key AND C.key = B.foreing key AND B.key = A.foreing key WHERE ..."
But I get SQL server2000 error : wrong sysntax near WHERE. I think the problem is "D LEFT JOIN C LEFT JOIN B LEFT JOIN A "... May be someone knows what is the problem?