已知一个学生选课管理系统,有学生信息管理(student),课程管理(course),老师信息管理(teacher),选课管理(sc)1.用SQL语句求出学生张三的所有代课老师姓名
Select t.tname from teacher t,sc where t.tid=sc.tid and sc.cid in (
Select sc.cid from student s sc where sc.sid=s.sid and s.sname=’张三’);2.用SQL语句求出学生选的最多的一门的代课老师名字3.用SQL语句删除课程名为‘离散数学’的课程。
Delete from sc where sc.cid=(select cid from course where cname=’ 离散数学’);
Delete from course where cname=’离散数学’;1,3题我做对了没有,2题想了半天没想出来

解决方案 »

  1.   

    2.用SQL语句求出学生选的最多的一门的代课老师名字 这个可以先 查询选课最多的一门学生做为 代课老师是子句 再查询老师的名字。楼主可以试试看
      

  2.   

    表关系:
    Create table student (sid number primary key,sname varchar2(10));
    Create table course(cid number primary key,cname varchar2(10),tid number references teacher(tid));
    Create table teacher(tid number,tname varchar2(10));
    Create table sc(sid references student(sid),cid references course(cid),unique(sid,cid));