I want to retrieve the course_id
in table course
that is not in the table takes
. Table takes
only contains course_id
of courses taken by students. The problem is that if I have:
select count (distinct course.course_id)
from course, takes
where course.course_id = (takes.course_id);
the result is 85 which is smaller than the total number of course_id
in table course
, which is 200. The result is correct.
But I want to find the number of course_id
that are not in the table takes
, and I have:
select count (distinct course.course_id)
from course, takes
where course.course_id != (takes.course_id);
The result is 200, which is equal the number of course_id
in table course
. What is wrong with my code?