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

sql课程编号教学

发布时间: 2022-09-14 21:13:09

‘壹’ sql多表查询,把课程编号显示成课程名

select T.courseName,S.courseName as prerequisitecourseName from (select courseName,prerequisitenumber from course a,prerequisitenumber b
where a.coursenumber=b.coursenumber)T ,course S
where T.prerequisitenumber =S.coursenumber

‘贰’ 如何用SQL查询全部学生都选了人课程号和课程名

1,全部学生都选了人课程号和课程名
select b.cno,b.cname
from 学生关系 a,课程关系 b,学习关系 c where a.sno=c.sno and b.cno=c.cno
group by b.cno,b.cname having count(*)=(select count(*) from 学生关系)

2,某位学生没有选的课程名称
select a.sname,b.cname
from 学生关系 a,课程关系 b,学习关系 c where a.sno=c.sno and b.cno=c.cno
group by a.sname,b.cname having count(*)<(select count(*) from 课程关系)

我这是列的每个学生没选的,要是查某位学生,加个条件就行
select a.sname,b.cname
from 学生关系 a,课程关系 b,学习关系 c where a.sno=c.sno and b.cno=c.cno
and a.sname='xxx'
group by a.sname,b.cname having count(*)<(select count(*) from 课程关系)

‘叁’ 用sql 查询哪些课程没有人选,要求列出课程编号和课程名称.

要看你没有人选是用什么表示,如果列名为“是否有人选”0表示没有人选的话,selcet
课程编号,课程名称
from
表名
where
是否有人选=0

‘肆’ 用SQL语句怎样在课程表中,查询出课程名中含有‘数据’的课编号及课程名

SELECT CourseId,CourseName FROM Course WHERE CourseName like '%数据%'

‘伍’ SQL查询全部学生都选修的课程的课程号和课程名问题

SELECT
course.cid,
course.cname
FROM
course JOIN study ON (course.cid = study.cid)
GROUP BY
course.cid,
course.cname
HAVING
COUNT(study.sid) = (SELECT COUNT(sid) FROM student);

逻辑:

首先,简单的把 课程表 与 选修表 关联
course JOIN study ON (course.cid = study.cid)

然后 ,按照 课程号和课程名 分组
GROUP BY
course.cid,
course.cname

最后, 要求 选修的人数 = 学生总数
HAVING
COUNT(study.sid) = (SELECT COUNT(sid) FROM student)

‘陆’ sql查询 在课程表查找学时不低于平均学时的课程编号、课程名、学时及学期。 求代码

在employee表中,求出每个课程的平均学时
select dept_no, AVG(e_salary) from employee group by dept_no
在employee表中,求出每个课程的平均学识大于平均学时的课程编号
select dept_no, AVG(e_salary) from employee group by dept_no having AVG(e_salary)>xxx(第一步运行的结果)
课程名、学时及学期直接在上面加就行了

‘柒’ SQL单表查询:查询课程表中课程编号为B20112021的课表所有信息

select * from 课程表
where 课程编号='B20112021'

‘捌’ 查询课程表中的课程编号,课程名称,教师,上课时间sql语句怎么打

select 课程编号,课程名称,教师,上课时间
from 课程表