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,'跆拳道');常用的sql查询语句有哪些
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