Stuck with some coding. I have to display the IT students enrolled in a certain course.
So this is my code so far, it displays the IT students names, but when it comes to showing the courses they’re enrolled in, it shows every single course available.
SELECT DISTINCT s.sid, s.sname, e.ccode
FROM student s, enrolled e
WHERE s.programme = 'IT';
I assume it’s to do with the WHERE s.programme = ‘IT’ line, it doesnt connect to the e.ccode, how do I do this?
This is a cross join, you need to have some join condition to filter the result. Other wise onr row of student will get joined with every row of enrolled table.
Assuming the enrolled table has a student id.