Ive a question relating to joins, in the code below im trying to find a tutor, who has free space, is in a certain faculty, doesnt have TU_ONLY and who doesnt have a preference for a certain course.
Basically it works for the first three criteria but it only returns a tutor who has an entry in tblPreference. A tutor does not need to have an entry in this table so i just want to find a tutor as long as they dont have a preference for this course.
Is it to do with my join-ive tried both inner and left joins
strsql2 = "SELECT TOP 1 tblTutor.TU_CODE " _
& "FROM (tblTutor LEFT JOIN [tblStudents] ON [tblTutor].TU_CODE = [tblStudents].STU_TU_CODE) " _
& "inner join tblPreference on (tblTutor.TU_CODE = tblPreference.TU_CODE) " _
& "GROUP BY tblTutor.TU_CODE, tblTutor.TU_CHAMBER_SIZE, tblTutor.TU_DP_NO, tblTutor.TU_FAC_NO, tblTutor.TU_COURSE, tblTutor.TU_ONLY, tblStudents.STU_TU_CODE, tblPreference.TU_CODE, tblPreference.TU_COURSE " _
& "HAVING ([TU_CHAMBER_SIZE] > (Count([tblStudents].STU_TU_CODE)) AND tblTutor.[TU_FAC_NO] = " & fac & " AND tblTutor.[TU_ONLY] = false AND tblPreference.[TU_COURSE] <> '" & course & "')"
Basically it works for the first three criteria but it only returns a tutor who has an entry in tblPreference. A tutor does not need to have an entry in this table so i just want to find a tutor as long as they dont have a preference for this course.
Is it to do with my join-ive tried both inner and left joins
strsql2 = "SELECT TOP 1 tblTutor.TU_CODE " _
& "FROM (tblTutor LEFT JOIN [tblStudents] ON [tblTutor].TU_CODE = [tblStudents].STU_TU_CODE) " _
& "inner join tblPreference on (tblTutor.TU_CODE = tblPreference.TU_CODE) " _
& "GROUP BY tblTutor.TU_CODE, tblTutor.TU_CHAMBER_SIZE, tblTutor.TU_DP_NO, tblTutor.TU_FAC_NO, tblTutor.TU_COURSE, tblTutor.TU_ONLY, tblStudents.STU_TU_CODE, tblPreference.TU_CODE, tblPreference.TU_COURSE " _
& "HAVING ([TU_CHAMBER_SIZE] > (Count([tblStudents].STU_TU_CODE)) AND tblTutor.[TU_FAC_NO] = " & fac & " AND tblTutor.[TU_ONLY] = false AND tblPreference.[TU_COURSE] <> '" & course & "')"