三个表关联查询
-- 查询选修了所有课程的学生姓名
SELECT sname FROM student WHERE
NOT EXISTS (SELECT cname FROM course WHERE
NOT EXISTS (SELECT id FROM sc WHERE
student.`sid`=sid AND course.`cid`=cid))
对查询结果的操作 1=‘智障’,2=‘傻逼’
SELECT sname,(SELECT
CASE WHEN statu = '1' THEN '傻逼'
WHEN statu = '2' THEN '智障'
ELSE '其他' END) AS statu
FROM student WHERE statu=1