There are two tables, students and courses. The students table has name, age and ssn.
Courses has ssn and Course.
Now the ssn in the courses table is NOT unique but the one in students is primary key.
I need to find out the students who are taking any of the classes that student C is taking (including C‘s name as well in the resulting solution).
It’s a challenge problem so I can just not mind it but I want to find out what the solution is.
So far I’ve tried to use a union operator like this :
SELECT ssn
FROM courses
UNION SELECT ssn
FROM students
WHERE name = 'c'
All this does is it returns all the ssns from the table courses. The question asks us to effectively find the set UNION of the both tables to determine the solution.
Any help is appreciated!
1 Answer