I am writing a query to join 3 tables, I have the following tables:
Apn [ID, QualHolderID, RecvDate, Barcode]
QualHolder [ID, Surname, FullName, DOB, ResCountryID, Gender]
Country [ID, Name]
Gender [ID, Name]
I wrote the following SQL statement to retrieve the data:
SELECT
a.QualHolderID, b.FullName, b.Surname, d.Name, b.DOB, b.ResCountryID, a.RecvDate
FROM
dbo.Apn a
INNER JOIN
dbo.QualHolder b ON a.QualHolderID = b.ID
JOIN
dbo.QualHolder c
INNER JOIN
dbo.Gender d ON c.Gender = d.ID
WHERE
b.ResCountryID = 48
But now I get the following error:
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near 'ID'.