失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > MySQL查询被选修的课程_sql语句查询没有被学生选修过的课程(即课程号没有在sc表中出现

MySQL查询被选修的课程_sql语句查询没有被学生选修过的课程(即课程号没有在sc表中出现

时间:2023-08-14 03:43:39

相关推荐

MySQL查询被选修的课程_sql语句查询没有被学生选修过的课程(即课程号没有在sc表中出现

展开全部

1、创建学生及课程表,

create table test_student(stu_id number, class_id number);

create table test_class(class_id number, class_name varchar2(30));

2、插入测试数据,

insert into test_student values(1,1001);

insert into test_student values(2,1001);

insert into test_student values(3,1002);

insert into test_student values(4,1003);

insert into test_student values(5,1003);

insert into test_student values(6,1003);

insert into test_class values(1001,'美术');

insert into test_class values(1002,'音乐');

insert into test_class values(1003,'绘画');

insert into test_class values(1004,'跆拳道');

3、查询学32313133353236313431303231363533e59b9ee7ad9431333431373861生选修的课程,

select * from test_student t, test_class b where t.class_id = b.class_id

4、查询无学生选修的课程,可以发现1004 跆拳道课程,无人选择,

select b.*

from test_student t, test_class b

where t.class_id(+) = b.class_id

and t.class_id is null

MySQL查询被选修的课程_sql语句查询没有被学生选修过的课程(即课程号没有在sc表中出现过)的名称....

如果觉得《MySQL查询被选修的课程_sql语句查询没有被学生选修过的课程(即课程号没有在sc表中出现》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。