练习4--查询"李"姓老师的数量|查询学过"张三"老师授课的同学的信息

-- 查询"李"姓老师的数量

select
    count(1)
from
    teacher
where
    t_name like '李%'

-- 查询学过"张三"老师授课的同学的信息

select
    t1.*
from
    student t1,
    score t2
where
    t1.s_id = t2.s_id
    and t2.c_id in (
        select c_id
    from
        course
    where
        t_id = (
            select t_id
        from
            teacher
        where
            t_name = '张三'));

 

select
    a.*
from
    student a
join score b on
    a.s_id = b.s_id
where
    b.c_id in(
    select
        c_id
    from
        course
    where
        t_id =(
        select
            t_id
        from
            teacher
        where
            t_name = '张三'));

 

--2019/04/18

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