Original Post
This is a completely game-unrelated question, but I found it as an exercise on a text book I was reading and I don't have anyone else to ask right now, so here it goes:
Given the following tables:
students = (id, name, age) classes = (name, classrom_number) inscriptions = (student_id, class_name)and the following SQL query:
SELECT name
FROM students
WHERE NOT EXIST(SELECT *
FROM inscriptions
WHERE NOT EXIST(SELECT *
FROM classes
WHERE classes.name = class_name AND
student_id = id))
determine what the query informs.
It seems to me that this query is wrong as the "student_id = id" condition in the innermost sub-query does not refer to the classes table which the query selects from, so this whole query shoudl either return an empty set or an error. Am I right?... Or maybe I don't fully understand SQL?
[edited by - Night Elf on April 16, 2004 6:31:44 PM]