|
You have to tell the database how the tables you want it to read from are related. The way your query is written, it's going to match every student with every next of kin, and match the Cartesian product with a particular course. You've explicitly limited the query to only one course, but you haven't given any guidance on how to pull only the students, etc, that are relevant for your report.
This needs a join clause. I'm guessing that there's a many to many relationship between students and courses (a student can take many courses, a course can be taught to many students), and that your next of kin table doesn't map between them. There's probably another table, ideally with a name like students_in_courses, that tells you student #1 is taking course #1 and course #2, whereas student #2 is taking course #38, etc. You'll need this in your query, to limit the Cartesian product you're seeing.
|