+-----------+-------+------+------+-------+
-- 查询计算机系中年龄大于19岁的学生,就是查询计算机系的学生与年龄不大于19岁的学生的差集,MySQL不支持EXCEPT操纵
SELECT * FROM student WHERE sdept='CS'
EXCEPT
SELECT * FROM student WHERE sage<=19
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 near 'EXCEPT
SELECT * FROM student WHERE sage<=19' at line 2
-- 用外连接或普通连接代替
SELECT a.* FROM student AS a LEFT JOIN student AS b ON a.sno=b.sno
WHERE a.sdept='CS'
AND b.sage>19
AND b.sno IS NOT NULL
SELECT * FROM student WHERE sdept='CS' AND sage>19;
+-----------+-------+------+------+-------+
(北联网教程,专业提供视频软件下载)
……