Het codevoorbeeld dat u liet zien, had ellipsen en ik geloof dat het de problemen in de ellipsen is.
Je hebt:
SELECT R.[ID], C.[name] AS [company], ...
FROM [requests] AS R, ...
LEFT OUTER JOIN [companies] AS C
ON R.[company_id] = S.ID
Laten we zeggen dat het zoiets is als:
SELECT R.[ID], C.[name] AS [company], X.Field
FROM [requests] AS R, [eXample] as X
LEFT OUTER JOIN [companies] AS C
ON R.[company_id] = S.ID
WHERE X.[request_id] = R.ID
Met andere woorden, het mengen van pre-ANSI 92 inner join-syntaxis met ANSI 92 outer join-syntaxis. Testen op SQL Server 2005, het lijkt erop dat de alias R voor verzoeken niet voorbij de komma wordt gezien die R scheidt van ... in uw voorbeeld, en [eXample] als X in het mijne. Het volgende werkte echter wel:
SELECT R.[ID], C.[name] AS [company], X.Field
FROM [eXample] as X, [requests] AS R
-- Requests and companies on the same side of the comma
LEFT OUTER JOIN [companies] AS C
ON R.[company_id] = S.ID
WHERE X.[request_id] = R.ID
of
SELECT R.[ID], C.[name] AS [company], X.Field
FROM [requests] AS R LEFT OUTER JOIN [companies] AS C
ON R.[company_id] = S.ID, [eXample] as X
WHERE X.[request_id] = R.ID
-- Yuck, I would hate to find this. Not at all sure from reading
-- the code how it would work.
of mijn favoriet, omdat ik ANSI 92 join-syntaxis leuk vind:
SELECT R.[ID], C.[name] AS [company], X.Field
FROM [requests] AS R
INNER JOIN [eXample] as X ON X.[request_id] = R.ID
LEFT OUTER JOIN [companies] AS C ON R.[company_id] = S.ID