I have a this select statement::
SELECT [Course ID], [Course name]
FROM Courses
WHERE [Course ID] NOT IN
(SELECT [Course ID] from student_courses sc
INNER JOIN Courses c ON sc.[course ID] = c.[course ID]
WHERE [student ID] = 1
AND (c.[course start time] not BETWEEN Courses.[course start time] AND Courses.[course end time]
OR c.[course end time] not BETWEEN Courses.[course start time] AND Courses.[course end time]))
it keeps giving the following errors::
The data types date and time are incompatible in the less than or equal to operator….
Ambiguous column name ‘Course ID’
How can I fix these errors and actually compare the column of data type time(7) ?
You need to convert the date to time i.e
and to get rid of the ambiguous column you need to add a alias to your table as student_courses and courses both have
courseId.Without running it the problem looks like its here in the subquery