I have 3 tables called Classes
, Courses
and Activitys
.
The Courses
and Classes
tables have the columns Id
and Name
. The Activitys
table has the columns ClassId
and CourseId
.
How do I show a list where I print the courses that the class doesnt have?
Output should look like this:
-Class- -Missing class-
class1 course1
class1 course3
class2 class 2
CLass 1 only have course 2
CLass 2 have course 1 and course 3
SELECT Name FROM Courses WHERE Id NOT IN (SELECT Id FROM Activitys WHERE ClassId = <Id> );
From the scratch of my head I'd try that. That should give you all the Courses that the chosen Class does not have.
<Id>
in the end has to be the Id of the class you want to check for.