--------------------------表結構--------------------------spa
student(StuId,StuName,StuAge,StuSex) 學生表code
teacher(TId,Tname) 教師表blog
course(CId,Cname,C_TId) 課程表class
sc(SId,S_CId,Score) 成績表查詢
----------------------------------------------------------di
問題十二:查詢至少學過學號爲「1001」同窗全部課程的其餘同窗學號和姓名co
SELECT st.StuId,st.StuName FROM student st INNER JOIN sc ON st.StuId=sc.SId WHERE sc.S_CId IN (SELECT S_CId FROM sc WHERE SId='1001') GROUP BY st.StuId HAVING COUNT(sc.S_CId)=(SELECT COUNT(*) FROM sc WHERE SId='1001') AND st.StuId<>'1001';
答案僅供參考,不必定徹底正確,若發現錯誤或有更好的,歡迎評論,互相交流,一塊兒成長!!!錯誤