I've got the following sql select statement which returns the information I want. It seems to work reliably although I have lots of left joins, tryomg to get the data out of for a pupil and any other related data. The only issue I seem to of stumbled on is returning the nationality data. My query is fine if a pupil has one nationality, however if they have two, I'd like to add/append the second value at the end of the first on the same row. Anyone advise me the best way to achieve this? Is this situation where I would use a subquery
SELECT p.pk_PupilID,p.PupilNumber,p.PupilStatus,pn.Surname ,pn. Forename,p.Form,d.DepartmentCode,p.BoardingStatus,e.StartTerm,e.StartAcademicYear,ny.Form,ny.BoardingStatus, c.Nationality
FROM Pupil p
LEFT JOIN Person pn ON p.pk_PupilID = pn.pk_PersonID
LEFT JOIN NextAcademicYear ny ON p.pk_PupilID = ny.fk_PupilID
LEFT JOIN Department d ON p.fk_DepartmentID=d.pk_DepartmentID
LEFT JOIN Enrolment e ON p.pk_PupilID=e.fk_PupilID
LEFT JOIN Nationality n ON p.pk_PupilID = n.fk_PersonID
LEFT JOIN Country c ON n.fk_ISO2Code = c.ISO2Code
WHERE p.pk_PupilID IN( '" & $IDs & "' )