十万火急!!求一份详细答案 谢谢了

CSDN阿坤 中科大脑 技术支持/维护工程师  2019-04-18 11:02:23
好心大佬帮帮忙哦……好人一生牛逼!
...全文
53 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kevin4id 2019-04-25
引用 1 楼 Kevin4id 的回复:


--创建一个学生管理数据库STUDENTDB
CREATE DATABASE STUDENTDB

--创建以上各表并添加相应数据
CREATE TABLE STUDENT
(
SNO VARCHAR(20),
SNAME VARCHAR(50),
SSEX VARCHAR(20),
SAGE INT,
SDEPT VARCHAR(15)
)

CREATE TABLE COURSE
(
CNO VARCHAR(20),
CNAME VARCHAR(50),
CPNO VARCHAR(10),
CCREIDET VARCHAR(15)
)

CREATE TABLE SC
(
SNO VARCHAR(20),
CNO VARCHAR(20),
GRADE VARCHAR(20)
)

INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215121','李勇','男','20','CS')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215122','刘晨','女','19','IS')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215123','王敏','女','18','MA')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215125','张立','男','18','IS')

INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('1','数据库','5','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('2','数学','','2')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('3','信息系统','1','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('4','操作系统','6','3')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('5','数据结构','7','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('6','数据处理','','2')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('7','C语言','6','4')

INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','1','92')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','2','85')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','3','88')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215122','2','90')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215122','3','80')

--在SC表中,查询学号为0215121学生的课程号与成绩
SELECT CNO,GRADE FROM SC WHERE SNO = '0215121'

--在COURSE表中,查询哪些课程没有预选课程号
SELECT * FROM COURSE WHERE CPNO = ''

--在STUDENT表中,查询IS系的学生姓名
SELECT SNAME FROM STUDENT WHERE SDEPT = 'IS'

--在STUDENT表中,查找姓“王”学生的基本信息
SELECT * FROM STUDENT WHERE SNAME LIKE '%王%'

--在COURSE表中,哪些课程的学分在3与4之间
SELECT * FROM COURSE WHERE CCREDIT BETWEEN '3' AND '4'
引用 1 楼 Kevin4id 的回复:


--创建一个学生管理数据库STUDENTDB
CREATE DATABASE STUDENTDB

--创建以上各表并添加相应数据
CREATE TABLE STUDENT
(
SNO VARCHAR(20),
SNAME VARCHAR(50),
SSEX VARCHAR(20),
SAGE INT,
SDEPT VARCHAR(15)
)

CREATE TABLE COURSE
(
CNO VARCHAR(20),
CNAME VARCHAR(50),
CPNO VARCHAR(10),
CCREDIT VARCHAR(15)
)

CREATE TABLE SC
(
SNO VARCHAR(20),
CNO VARCHAR(20),
GRADE VARCHAR(20)
)

INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215121','李勇','男','20','CS')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215122','刘晨','女','19','IS')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215123','王敏','女','18','MA')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215125','张立','男','18','IS')

INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('1','数据库','5','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('2','数学','','2')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('3','信息系统','1','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('4','操作系统','6','3')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('5','数据结构','7','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('6','数据处理','','2')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREDIT )VALUES('7','C语言','6','4')

INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','1','92')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','2','85')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','3','88')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215122','2','90')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215122','3','80')

--在SC表中,查询学号为0215121学生的课程号与成绩
SELECT CNO,GRADE FROM SC WHERE SNO = '0215121'

--在COURSE表中,查询哪些课程没有预选课程号
SELECT * FROM COURSE WHERE CPNO = ''

--在STUDENT表中,查询IS系的学生姓名
SELECT SNAME FROM STUDENT WHERE SDEPT = 'IS'

--在STUDENT表中,查找姓“王”学生的基本信息
SELECT * FROM STUDENT WHERE SNAME LIKE '%王%'

--在COURSE表中,哪些课程的学分在3与4之间
SELECT * FROM COURSE WHERE CCREDIT BETWEEN '3' AND '4'
回复
Kevin4id 2019-04-25


--创建一个学生管理数据库STUDENTDB
CREATE DATABASE STUDENTDB

--创建以上各表并添加相应数据
CREATE TABLE STUDENT
(
SNO VARCHAR(20),
SNAME VARCHAR(50),
SSEX VARCHAR(20),
SAGE INT,
SDEPT VARCHAR(15)
)

CREATE TABLE COURSE
(
CNO VARCHAR(20),
CNAME VARCHAR(50),
CPNO VARCHAR(10),
CCREIDET VARCHAR(15)
)

CREATE TABLE SC
(
SNO VARCHAR(20),
CNO VARCHAR(20),
GRADE VARCHAR(20)
)

INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215121','李勇','男','20','CS')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215122','刘晨','女','19','IS')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215123','王敏','女','18','MA')
INSERT INTO STUDENT (SNO,SNAME,SSEX,SAGE,SDEPT)VALUES('0215125','张立','男','18','IS')

INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('1','数据库','5','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('2','数学','','2')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('3','信息系统','1','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('4','操作系统','6','3')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('5','数据结构','7','4')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('6','数据处理','','2')
INSERT INTO COURSE (CNO,CNAME,CPNO,CCREIDET)VALUES('7','C语言','6','4')

INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','1','92')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','2','85')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215121','3','88')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215122','2','90')
INSERT INTO SC (SNO,CNO,GRADE)VALUES('0215122','3','80')

--在SC表中,查询学号为0215121学生的课程号与成绩
SELECT CNO,GRADE FROM SC WHERE SNO = '0215121'

--在COURSE表中,查询哪些课程没有预选课程号
SELECT * FROM COURSE WHERE CPNO = ''

--在STUDENT表中,查询IS系的学生姓名
SELECT SNAME FROM STUDENT WHERE SDEPT = 'IS'

--在STUDENT表中,查找姓“王”学生的基本信息
SELECT * FROM STUDENT WHERE SNAME LIKE '%王%'

--在COURSE表中,哪些课程的学分在3与4之间
SELECT * FROM COURSE WHERE CCREDIT BETWEEN '3' AND '4'
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2019-04-18 11:02
社区公告
暂无公告