create table UserInfo--学生表
(
Id int primary key identity(1,1) not null,
UserName varchar(50) not null,
ClassId int not null--班级ID,对应ClassInfo的ID
)
GO
create table ClassInfo--班级表
(
Id int primary key identity(1,1) not null,
ClassName varchar(50) not null
)
GO
create table SubjectInfo--考试科目表
(
Id int primary key identity(1,1) not null,
SubjectName varchar(50) not null
)
GO
create table ExamInfo--考试信息表
(
Id int primary key identity(1,1) not null,
Uid int not null,--学生ID,对应UserInfo的Id
Sid int not null,--科目ID,对应SubjectInfo的Id,
ExamDate datetime not null--考试时间
)
有很多字段都省略了,只写出了主要的问题1: 查询所有没有参加考试的学生、学生班级及对应科目
问题2: 根据科目ID查询出所有没有参加该科目考试的学生及学生班级
问题3: 根据班级ID查询出该班级所有没有参加考试的学生及科目
要求:以上全部用存储过程实现,并要分页我实在写不出来,大家帮帮忙
解决方案 »
- 请问一个分区的问题,我想按类型Id分区,或者地区ID,怎么分区
- phpmysql字符串拼接
- curl真的没有对采集内容进行字节限制的设置么?例如我只想要网页的header部分的keyword,全部都采集过来的话太浪费了
- 急!!string经过zip之后存在SQL Server的image字段,PHP怎么取出字段显示呢
- 关于str_replace()函数的问题,忘高手解答,谢谢
- paypal支付完後如何得知它操作成功?
- 写了一个函数,大家看有没有bug啊?
- 关于robots.txt文件请大家帮忙看一下
- 从mysql的DATE数据中提取时间
- 如何按月份搜索??
- WAMP环境设置完成(感觉是完成),Localhost需要输入帐户和密码!!!求助!!
- apache 启动错误
select u.*,s.*
from UserInfo u,SubjectInfo s
where not exists (select * from ExamInfo where Uid=u.Uid and Sid=s.Sid)分页你就自己用 top 来吧。
表subjectinfo应该还要添加一个classid字段,因为不同班级所学的科目可能不同。
第一题:select ui.username,ci.classname,si.subjectname
from userinfo ui,classinfo ci,subjectinfo si,examinfo ei
where ui.classid=ci.id and ei.sid=si.id
and ui.id not in
(select uid from examinfo where sid=si.id);第二题:select ui.username,ci.classname
from userinfo ui,classinfo ci
where ui.classid=ci.id and
not exists
(select 1 from examinfo
where sid=1 and uid=ui.id);第三题:select ui.username,si.subjectname
from userinfo ui,subjectinfo si
where ui.classid=1 and not exists
(select 1 from classinfo ci,examinfo ei
where ui.classid=ci.id and ui.id=ei.uid
and si.id=ei.sid);