I have 2 tables
requests
(ID
, company_id
, amount
)
companies
(ID
, name
)
with FK constraint (requests.company_id
-> companies.id
)
requests.company
can be NULL
I need to get all requests and replace company_id
with appropriated company name
or left it blank if no company was specified.
I have next query:
SELECT R.[ID], C.[name] AS [company], R.[amount], ...
FROM [requests] AS R, [companies] AS C, ...
WHERE R.[company_id] = C.[ID]
and it's working fine until a NULL into company
field.
I tried to do next:
SELECT R.[ID], C.[name] AS [company], ...
FROM [requests] AS R, ...
LEFT OUTER JOIN [companies] AS C
ON R.[company_id] = S.ID
But got
The multi-part identifier "R.company_id" could not be bound
And the same errors on fields in ON
clause shifting. What am I doing wrong?