34,588
社区成员
发帖
与我相关
我的任务
分享
select 学号 ,姓名 from student where sc in (select sc from sc group by sc having count(*) + (select count(*) from sc where 学号 = 'S3'))
select student.学号,姓名 from student inner join sc
on student.学号=sc.学号 where 课程号 in
(select s.课程号 from sc s inner join course c
on s.课程号= c.课程号
where s.学号 = 's3')
select * from student
where 学号 in(
select a.学号 from
(select * from sc where 学号<>'s3') a
join (select * from sc where 学号='s3') b
on a.课程号=b.课程号 group by a.学号
having count(1)=(select count(1) from sc where 学号='s3'))
select 学号,姓名 from stuent
where 学号=(select 学号 from sc
where 课程号=(select 课程号 from sc where 学号='s3'))
写多一种方法,或用in方法
select
*
from
STUDENT a
where
not exists(select 1 from sc b left join sc c on b.课程号=c.课程号 and c.学号=a.学号 where b.学号='S3' and c.课程号 is null)
select
*
from
STUDENT a
where
not exists(
select * from sc b where 学号='S3' and not exists(select 1 from Sc where 学号=a.学号 and 课程号=b.课程号))
select
*
from
STUDENT a
from
where
not exists(
select * from sc b where 学号='S3' and not exists(select 1 from Sc where 学号=a.学号 and 课程号=b.课程号))