当前位置:首页 » 编程语言 » 选课时间用sql怎么表示
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

选课时间用sql怎么表示

发布时间: 2022-11-26 05:52:25

① 要查询选修了所有课程的学生信息,怎样用sql实现

第一问:两个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 cno=course.cno) 的课,只不过用not exists否定掉了*/

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

② 关于学生,课程,选课三张表的sql查询

select 选课.学号,姓名,AVG(成绩)'平均分',COUNT(选课.课程号)'选课门数' from 学生,课程,选课 where 学生.学号=选课.学号 and 课程.课程号=选课.课程号 group by 选课.学号,姓名 HAVING COUNT(选课.课程号)>4 ORDER BY AVG(成绩) DESC
--------------------------------------
CREATE VIEW 查询 AS
select top 100 选课.学号,姓名,AVG(成绩)'平均分',COUNT(选课.课程号)'选课门数' from 学生,课程,选课 where 学生.学号=选课.学号 and 课程.课程号=选课.课程号 group by 选课.学号,姓名 HAVING COUNT(选课.课程号)>4 ORDER BY AVG(成绩) DESC

其中DESC是降序排列,ASC是升序排列,默认是升序
ORDER BY AVG(成绩)也可以写成ORDER BY 平均分,因为已经指定了别名
“CREATE VIEW 查询”中的“查询”是新表名, 如果有“ORDER BY AVG(成绩) DESC ”这句,则须有“top”,否则出错“除非同时指定了 TOP,否则 ORDER BY 子句在视图、内嵌函数、派生表和子查询中无效。”

③ 急求!!!用SQL查询学生的所有选课信息的语句该怎么写前面已经建好了Student、Course和SC的表了

selectstudent.sname,course.cname--查询学生名,课程名
fromstudent,course,scwherestudent.sno=sc.snoandcourse.cno=sc.cno--三个表之间的关联
orderbystudent.sname--按姓名排序

字段名有跟你不一样的,自行修改一下

④ 怎么用sql语句查询一个学生的选课情况,并列出课程信息

selectstu.name,course.*
fromstu,course,chicewherestu.sid=chice.sidandcourse.c_id=choice.c_id
andstu.name='张三'--这个地方输入你想查的人名,如果这句不写则查询全部

⑤ 选课系统,可以根据专业不同动态的选择课程,用sql语句实现。

这个是简单的两个下拉框之间的组合查询,你要做的是在第一个下拉框绑定事件,然后再这个时间里面,根据第一个下拉框选择的值,来绑定第二个下拉框的值,
怎么绑定下拉框和写事件,不需要教你吧

⑥ 怎么写sql的语句

1.update 选课 set 成绩=成绩+5 where 课程号 in (select 课程号 from 课程 where 课程名="数据库"x0dx0a2.update 选课 set 成绩=0 where 课程号="2"x0dx0a3.update 选课 set 成绩=85 where 学号 in (select 学号 from 学生 where 姓名="李勇"x0dx0a4.delete from 选课 where 课程号="2" and 成绩 is nullx0dx0a5.delete from 课程 where 课程号 not in (select 课程号 from 选课)x0dx0a6.delete from 选课 where 课程号 in (select 课程号 from 课程名="数据库") and 学号 in (select 学号 from 学生 where 系名="计算机")x0dx0a7.select 系名,sum(*) as 人数 from 学生 group by 系名,性别 into table 学生分类x0dx0a8.select 学号,count(*) as 课程数,avg(成绩) as 平均成绩 from 选课 where avg(成绩)>=80 into table 成绩表x0dx0a9.create view 无选修 as select 学号,姓名,系名 from 学生 where 学号 not in (select 学号 from 选课)x0dx0aselect * from 无选修x0dx0a10. create view 成绩 as select 姓名,课程名,成绩 from 学生,课程,选课 where 学生.学号=选课.学号 and 选课.课程号=课程.课程号 x0dx0aselect * from 成绩x0dx0a11.create view 平均 as select 课程号,count(*) as 选课人数,avg(成绩) as 平均分,max(成绩) as 最高分 from 选课 group by 课程号x0dx0aselect 选课人数,平均分,最高分 from 平均 where 课程号="1"x0dx0a12.create view 平均1 as select 学号,成绩 from 选课 where 课程号="2" and 成绩>(select avg(成绩) from 选课 where 课程号="2")

⑦ SQL中在成绩表中增加“选课时间”字段,日期型,默认值为当前系统日期。的命令怎么写 啊

Alter table 成绩表
add 选课时间 datetime default getdate()

⑧ SQL选课表如何判断选课时间重复

这个你描述的不是很清楚
如果是表里的数据 可以分组查数量
例如
select name ,count(*) from table_name where shijian=** group by name having count(*)>1
但是如果表中没有,是新增数据 ,则
let v_count = select count(*)from table_name where shijian=**
if v_count=0 then
insert ****
else
时间重复