SQL 练习2
-
查询同时存在" 01 "课程和" 02 "课程的情况
-
分析:分别先查询出包含有01课程和02课程
SELECT * from sc WHERE cid='01' SELECT * from sc WHERE cid='02'
-
最终代码
SELECT SId, sname ,sage FROM Student WHERE SId IN (
SELECT t1.sid from (SELECT * FROM sc WHERE cid = '01') as t1, (SELECT * FROM sc WHERE cid = '02') as t2 WHERE t1.sid = t2.sid)
本文来自博客园,作者:弩哥++,转载请注明原文链接:https://www.cnblogs.com/bangbangzoutianya/p/15156831.html