SQL嵌套查询,相关子查询not exists实现全称量词的案例

use stu
select cno,cname 
from course
where not exists(
				select * from sc where sno = '201215121' and cno=course.cno
				)

select sname 
from student
where sno in(
			select sno
			from sc
			group by sc.sno
			having count(*) = (
								select count(*)
								from course
								)
			)


select sname
from student
where not exists
		(
			select *
			from course
			where not exists(
								select *
								from sc
								where sno = student.sno
								and   cno = course.cno
							)
		)

select sname
from student
where not exists
		(
			select *
			from (select cno from sc where sno = 201215122) x
			where not exists(
								select *
								from sc
								where sno = student.sno
								and   cno = x.cno
							)
		)
posted @ 2025-04-18 09:49  嘉君  阅读(10)  评论(0)    收藏  举报