SQL查询没有选修1号课程的学生姓名

2021-01-05 15:22:38 字数 5144 阅读 8942

1楼:匿名用户

selectsname

fromstudent

wherenotexists

(select*

fromsc

wherestudent.sno=sc.snoand**o='1');

2楼:匿名用户

select [姓名(sname)] from student where not exists (select *

3楼:匿名用户

from sc where sno=student.[学号(sno)] and **o='1');

数据库中,用sql语言如何查询没有选修1号课程的学生姓名

4楼:哈皮的小逗比

student--学生表

student_id,

student_name,

student_no

course--课程表

course_id,

course_name

sc--选课信息表

student_id,

course_id

select *

from student

where student_id not in(select student_id

from sc

where course_id in

(select course_id from course where course_name = '1号课程'))

5楼:冉涵阳翁隽

假设学生表为a,学号字段为id,姓名字段为name;

课程表为b,其中row_id为课程编号,stu_no为选修该门课的学生的学号

sql:

select

a.id,a.name

from

awhere

a.id

notin

(select

distinct

b.stu_no

fromb)

6楼:匿名用户

selectsname

fromstudent

wherenotexists

(select*

fromsc

wherestudent.sno=sc.snoand**o='1');

sql查询没有同时选修1号课程和2号课程学生的学号

7楼:匿名用户

select distinct sno

from sc

where sno not in

(select sno

from sc

where **o='1' and sno in(select sno

from sc

where **o='5'))

这是一般的变法,还可用集合查询,关键字intersectselect distinct sno

from sc

where sno not in

(select sno

from sc

where **o='1'

intersect

select sno

from sc

where **o='5')

8楼:匿名用户

select s.学号

from student s,course c,sc scwhere s.学号=sc.学号 and c.课程号=sc.课程号 and

c.课程号='1'

union

select s.学号

from student s,course c,sc scwhere s.学号=sc.学号 and c.课程号=sc.课程号 and

c.课程号='2'

9楼:凌动小生

select distinct sc.sno where sc.**o !='课程1'and sc.**o !='课程2'

10楼:匿名用户

select sno where [sc] **o='选修1号' and **o='选修2号' order by sno

求用sql语言在数据库中查找没有选修任何课程的学生的学号,姓名的命令?

11楼:匿名用户

假设学生表为

a,学号字段为id,姓名字段为name;

课程表为b,其中row_id为课程编号,stu_no为选修该门课的学生的学号

sql:

select a.id,a.name

from a

where a.id not in (select distinct b.stu_no from b)

12楼:匿名用户

应为三张表:

学生表a 课程表b 选修表c(cid aid bid)--没有选修任何课程的学生的学号

select*fromawhereaidnotin(selectdistinctaidfromc)--为已选修的人

如有问题可以追问,我当及时回答.

希望能帮到你!

13楼:抽插小旋风

select 学号,姓名 from 表 where 选修课程 is null

或者select 学号,姓名 from 表 where 选修课程 =‘’

如何用sql语言在数据库中查找没有选修任何课程的学生的学号,姓名的命令?

14楼:匿名用户

假设学生表为

a,学号字段为id,姓名字段为name;

课程表为b,其中row_id为课程编号,stu_no为选修该门课的学生的学号

sql:

select a.id,a.name

from a

where a.id not in (select distinct b.stu_no from b)

数据库 查询所有没选修“0401010103”课程的学生学号及姓名

15楼:匿名用户

select stud_id,name

from table

where course_id<>'0401010103'

sql查询全部课程选修的学生姓名,怎么得出某同学没有选课?

16楼:匿名用户

分析原因如下:

第一问:两个not exists表示双重否定:没有一个选了课的学生没有选course表里的课程

select sname from student where not exists /*没有一个学生满足以下条件*/

(select * from course where not exists /*什么条件呢?没有选过course表里的课*/

(select * from sc where sno =student.sno /*这里两个=分别指对应的关系,表示选

过课并且是course里and **o=course.**o) 的课,只不过用not exists否定掉了*/

第二问:其实和not in 是一个意思 exists只返回true 或false 这里not exists里的内容 其实就 是指学生选过的课程,再用not exists否定了,就变成了没有选

linqpad查询没有选修1号课程的学生姓名? 5

sql查询选修了全部课程的学生姓名

17楼:狠有毅毅

第一问:两个not exists表示双重否定:没有一个选了课的学生没有选course表里的课程

select sname

from student

where not exists /*没有一个学生满足以下条件*/

(select * from course

where not exists /*什么条件呢?没有选过course表里的课*/

(select * from sc

where sno =student.sno /*这里两个=分别指对应的关系,表示选过课并且是course里and **o=course.**o) 的课,只不过用not exists否定掉了*/

第二问:其实和not in 是一个意思 exists只返回true 或false 这里not exists里的内容 其实就是指学生选过的课程,再用not exists否定了,就变成了没有选的

18楼:匿名用户

分析原因如下:

第一问:两个not exists表示双重否定:没有

一个选了课的学生没有选course表里的课程

select sname from student where not exists /*没有一个学生满足以下条件*/

(select * from course where not exists /*什么条件呢?没有选过course表里的课*/

(select * from sc where sno =student.sno /*这里两个=分别指对应的关系,表示选

过课并且是course里and **o=course.**o) 的课,只不过用not exists否定掉了*/

第二问:其实和not in 是一个意思 exists只返回true 或false 这里not exists里的内容 其实就 是指学生选过的课程,再用not exists否定了,就变成了没有选

19楼:匿名用户

exists 是类似于in 效率比in 好的多

not exists 类似于 not in 效率一样比not in 一样好的多

再来看这个sql语句,应该明白了吧

数据库中查询全部学生都选修了的课程号和课程名

1楼 select 课程 课程号 课程 课程名 from 课程 where 课程号 in select distinct 课程号 from 选课group by 课程号 having count select count from 学生 根据人数判断 ,比较土,可以这样试试。 2楼 匿名用户 楼上回...

查询选修了3门以上课程的学生学号

1楼 匿名用户 其实是可以的,只是教科书的不完整而已 select sno from sc group by sno having count 3 表示对任意列的统计,然后如果填写特定列比如 count o 则不会计算该列含有null的记录 比如 o12 null count 的结果为3 count...

使用SQL语句删除没有学生选修的课程记录

1楼 匿名用户 这个我也答了 delete from 课程 where 课程号 not in select 课程号 from 选课 使用sql语句删除没有学生选修的课程记录 2楼 匿名用户 delete from 课程 where 课程号 not in select 课程号 from 选课 3楼 匿...