当前位置: 代码迷 >> Sql Server >> 弱弱的个查询语句有关问题
  详细解决方案

弱弱的个查询语句有关问题

热度:16   发布时间:2016-04-24 22:55:03.0
弱弱的求助个查询语句问题
小弟刚入门SQL 数据库学习  
有三张表  XSB(学生表),KCB(课程表),CJB(成绩表),现在有以下查询语句,烦请大神给详细解释下语句的意思,第一层嵌套  第二层嵌套等
select * from XSB where not exists 
     (
         select * from KCB  where not exists
       (
           select * from cjb where  cjb.学号=XSB.学号 and cjb.课程号=KCB.课程号
         )
     )

实在是看不太懂

------解决方案--------------------
引用:
引用:select * from XSB
where 学号 in 
(select 学号 from CJB group by 课程号 having count(*)=(select count(*) from KCB)
)
先从括号里看,哪不懂问我

用你的语句执行报错
选择列表中的列 'CJB.学号' 无效,因为……



我的错... 我写错了
select * from XSB
where 学号 in 
(select 学号 from CJB group by 学号 having count(*)=(select count(*) from KCB)
)
  相关解决方案