SQL 练习2

  • 查询同时存在" 01 "课程和" 02 "课程的情况

  • 分析:分别先查询出包含有01课程和02课程

    SELECT * from sc WHERE cid='01'
    SELECT * from sc WHERE cid='02'
    

    image

  • 最终代码

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)

image

posted @ 2021-08-18 15:08  弩哥++  阅读(45)  评论(0编辑  收藏  举报