Oracle 查询。。。
createtablestudent(snovarchar2(10)primarykey,snamevarchar2(20),sagenumber(2),ssexvarc...
create table student(
sno varchar2(10) primary key,
sname varchar2(20),
sage number(2),
ssex varchar2(5)
);
create table teacher(
tno varchar2(10) primary key,
tname varchar2(20)
);
create table course(
cno varchar2(10),
cname varchar2(20),
tno varchar2(20),
constraint pk_course primary key (cno,tno)
);
create table sc(
sno varchar2(10),
cno varchar2(10),
score number(4,2),
constraint pk_sc primary key (sno,cno)
);
insert into student values ('s001','张三',23,'男');
insert into student values ('s002','李四',23,'男');
insert into student values ('s003','吴鹏',25,'男');
insert into student values ('s004','琴沁',20,'女');
insert into student values ('s005','王丽',20,'女');
insert into student values ('s006','李波',21,'男');
insert into student values ('s007','刘玉',21,'男');
insert into student values ('s008','萧蓉',21,'女');
insert into student values ('s009','陈萧晓',23,'女');
insert into student values ('s010','陈美',22,'女');
commit;
/******************初始化教师表***********************/
insert into teacher values ('t001', '刘阳');
insert into teacher values ('t002', '谌燕');
insert into teacher values ('t003', '胡明星');
commit;
/***************初始化课程表****************************/
insert into course values ('c001','J2SE','t002');
insert into course values ('c002','Java Web','t002');
insert into course values ('c003','SSH','t001');
insert into course values ('c004','Oracle','t001');
insert into course values ('c005','SQL SERVER 2005','t003');
insert into course values ('c006','C#','t003');
insert into course values ('c007','JavaScript','t002');
insert into course values ('c008','DIV+CSS','t001');
insert into course values ('c009','PHP','t003');
insert into course values ('c010','EJB3.0','t002');
commit;
/***************初始化成绩表***********************/
insert into sc values ('s001','c001',78.9);
insert into sc values ('s002','c001',80.9);
insert into sc values ('s003','c001',81.9);
insert into sc values ('s004','c001',60.9);
insert into sc values ('s001','c002',82.9);
insert into sc values ('s002','c002',72.9);
insert into sc values ('s003','c002',81.9);
insert into sc values ('s001','c003','59');
commit;
查询和“s001”号的同学学习的课程完全相同的其他同学学号和姓名; 展开
sno varchar2(10) primary key,
sname varchar2(20),
sage number(2),
ssex varchar2(5)
);
create table teacher(
tno varchar2(10) primary key,
tname varchar2(20)
);
create table course(
cno varchar2(10),
cname varchar2(20),
tno varchar2(20),
constraint pk_course primary key (cno,tno)
);
create table sc(
sno varchar2(10),
cno varchar2(10),
score number(4,2),
constraint pk_sc primary key (sno,cno)
);
insert into student values ('s001','张三',23,'男');
insert into student values ('s002','李四',23,'男');
insert into student values ('s003','吴鹏',25,'男');
insert into student values ('s004','琴沁',20,'女');
insert into student values ('s005','王丽',20,'女');
insert into student values ('s006','李波',21,'男');
insert into student values ('s007','刘玉',21,'男');
insert into student values ('s008','萧蓉',21,'女');
insert into student values ('s009','陈萧晓',23,'女');
insert into student values ('s010','陈美',22,'女');
commit;
/******************初始化教师表***********************/
insert into teacher values ('t001', '刘阳');
insert into teacher values ('t002', '谌燕');
insert into teacher values ('t003', '胡明星');
commit;
/***************初始化课程表****************************/
insert into course values ('c001','J2SE','t002');
insert into course values ('c002','Java Web','t002');
insert into course values ('c003','SSH','t001');
insert into course values ('c004','Oracle','t001');
insert into course values ('c005','SQL SERVER 2005','t003');
insert into course values ('c006','C#','t003');
insert into course values ('c007','JavaScript','t002');
insert into course values ('c008','DIV+CSS','t001');
insert into course values ('c009','PHP','t003');
insert into course values ('c010','EJB3.0','t002');
commit;
/***************初始化成绩表***********************/
insert into sc values ('s001','c001',78.9);
insert into sc values ('s002','c001',80.9);
insert into sc values ('s003','c001',81.9);
insert into sc values ('s004','c001',60.9);
insert into sc values ('s001','c002',82.9);
insert into sc values ('s002','c002',72.9);
insert into sc values ('s003','c002',81.9);
insert into sc values ('s001','c003','59');
commit;
查询和“s001”号的同学学习的课程完全相同的其他同学学号和姓名; 展开
3个回答
展开全部
你这里只需要根据“s001”号的同学学习的课程,找到选择了这些课程的同学学号、姓名
两张表就可以了。
你是这个意思吧,选择了和s001一摸一样的课程的同学:
select sno,sname from student
where sno in(select sno from
(select s.sno,sname, cno from student s,sc sc
where s.sno=sc.sno and cno in(select cno from sc where sno='s001') ) a
group by sno
having count(cno)=(select count(cno) from sc where sno='s001'))
不要学生's001',可以在where后面加 and sno!='s001'
两张表就可以了。
你是这个意思吧,选择了和s001一摸一样的课程的同学:
select sno,sname from student
where sno in(select sno from
(select s.sno,sname, cno from student s,sc sc
where s.sno=sc.sno and cno in(select cno from sc where sno='s001') ) a
group by sno
having count(cno)=(select count(cno) from sc where sno='s001'))
不要学生's001',可以在where后面加 and sno!='s001'
追问
是这个意思 (⊙o⊙)哦了。。。醒了。。。谢了
仁科信息
2024-07-24 广告
2024-07-24 广告
Oracle EBS运维是确保企业资源规划系统稳定、高效运行的关键环节。它涵盖了系统监控、性能优化、故障排查与恢复等多方面内容。通过持续的监控和数据分析,运维团队能够及时发现并解决潜在问题,保障系统的稳定性和安全性。同时,他们还需要与业务部...
点击进入详情页
本回答由仁科信息提供
展开全部
0.0 这个 同学 你去看看多表查询问题吧 很简单的... where语句限定就好了 不要老想着问 我学ORACLE 到现在还不到四个月 我看了3天书开始在电脑上操作的 一星期开始干工作
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select sno,sname from student as st , course as co,sc where cno=(select cno from course where sno='s001') ) and co.cno=sc.cno and st.sno=sc.sno
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询