How can i merge the rows of a teachers qualification from its table to a single row and join it to another so i can search for a given condition to know if a teacher possesses the given degree/certification. Or is there a better approach other than the one i am trying to use? Thanks in advance. Second image.
SELECT
StaffTable.TeacherType,
StaffTable.StaffID,
TeacherQualificationsTable.YearOfGraduation,
TeacherQualificationsTable.SubjectMajorsCombination,
STUFF((SELECT
', ' + [DegreeObtained]
FROM
TeacherQualificationsTable FOR XML PATH('')),1,1,'') AS [DegreeObtained]
FROM
StaffTable
INNER JOIN
TeacherQualificationsTable
ON
StaffTable.StaffID = TeacherQualificationsTable.StaffID
INNER JOIN
AppointmentChronologyTable ON StaffTable.StaffID = AppointmentChronologyTable.StaffID
WHERE
(StaffTable.TeacherType = @TeacherType)
AND (StaffTable.StaffStatus = @StaffStatus)
AND DegreeObtained NOT CONTAINS ('B.Ed (Bachelor of Education)' , 'M.Ed (Master of Education)', 'G.D.E (Graduate Diploma in Education)')
ORDER BY
StaffTable.LastName,
StaffTable.FirstName,
StaffTable.MiddleName
I have a staffTable and a staffQualificationsTable (which will have multiple qualification entries for any given staff). Am required to check if some staff have some given qualifications eg 'B.Ed (Bachelor of Education)' , 'M.Ed (Master of Education)', 'G.D.E (Graduate Diploma in Education)' and return all the staff without it so they will be called to tender theirs or laid off. Please, i hope this is clearer.