练习7--查询没学过"张三"老师讲授的任一门课程的学生姓名

-- 查询没学过"张三"老师讲授的任一门课程的学生姓名 

select
    s_name
from
    student
where
    s_id not in (
    select
        distinct s_id
    from
        score
    where
        c_id in (
            select t2.c_id
        from
            teacher t1,
            course t2
        where
            t1.t_id = t2.t_id
            and t1.t_name = '张三'))
select
    a.s_name
from
    student a
where
    a.s_id not in (
    select
        s_id
    from
        score
    where
        c_id = (
            select c_id
        from
            course
        where
            t_id =(
            select
                t_id
            from
                teacher
            where
                t_name = '张三'))
    group by
        s_id);

 

-- 2019/04/24

posted @ 2019-04-24 22:24  熊猫橙子  阅读(5430)  评论(0)    收藏  举报