此查询有效:
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)
此查询也有效:
mysql> SELECT t.sno FROM take t WHERE t.cno = 'CS112';
+------+
| sno |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
+------+
4 rows in set (0.00 sec)
但是这个查询:
SELECT s.sno FROM students s
EXCEPT
SELECT t.sno FROM take t WHERE t.cno = 'CS112';
失败并出现错误:
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
我在这里做错了什么?