This query works:
mysql> SELECT s.sno FROM students s;
+------+
| sno |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+------+
10 rows in set (0.00 sec)
This query also works:
mysql> SELECT t.sno FROM take t WHERE t.cno = 'CS112';
+------+
| sno |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
+------+
4 rows in set (0.00 sec)
BUT this query:
SELECT s.sno FROM students s
EXCEPT
SELECT t.sno FROM take t WHERE t.cno = 'CS112';
fails with the error:
mysql> SELECT s.sno FROM students s
-> EXCEPT
-> SELECT t.sno FROM take t WHERE t.cno = 'CS112';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use n
ear 'EXCEPT
SELECT t.sno FROM take t WHERE t.cno = 'CS112'' at line 2
What am I doing wrong here?
EXCEPT
. Your alternative though does not produce the correct result. – Inaudible