I'm running this query in MYSQL and I'm getting the error 1241: Operand should contain 1 column(s).
I want to know the names and student id's of the students enrolled in Database Management Systems and Knowledge Discovery in Databases (both course titles in the CoursesOffer table)
- Students(stuID: String, stuName: String, gender: String, birthdate: Date, enterYear: Year, gpa: Float)
- Departments(deptName: String, numPhDs: Integer)
- ProfessorWorks(profID: String, profName: String, deptName: String)
- CoursesOffer(cNo: String, cTitle: String, deptName: String)
- Majors(deptName: String, stuID: String, degreeProgram: String, attendYear: Year, attendSemester: String)
- Sections(cNo: String, semester: String, sectNo: String, profID: String)
- Enrolls(stuID: String, cNo: String, sectNo: String, semester: String, grade: String)
My query looks like
SELECT S.StuName, S.StuID
FROM Students S NATURAL JOIN CoursesOffer C NATURAL JOIN Enrolls E
WHERE cTitle='Database Management Systems'
IN (
SELECT S2.StuName, S2.StuID
FROM Students S2 NATURAL JOIN CoursesOffer C2 NATURAL JOIN Enrolls E2
WHERE cTitle='Knowledge Discovery in Databases');
IN
is (logical) operator for the WHERE clause, it is used in the formval1 IN (<list fo values or a subquery>)
and can be "extended" to use tuples like(val1, val2) IN (<list of pairs>)
- so reading your code what you wrote seems to mean: "compare cTitle to 'Database Management Systems' and then check the result (0 or 1 for false/true) using the IN operator" - but it expects to get ONE column only to compare to the 0/1