子查询

子查询是一种常用计算机语言SELECT-SQL语言中嵌套查询下层的程序模块。当一个查询是另一个查询的条件时,称之为子查询。

# 子查询的用法
# 在字段
select (select cName from courses where cNo = cID) as '课程名称', count(elNo) from elogs GROUP BY cID;

# 在表
select * from courses where exists(
    select * from (select sum(cCredit) as sumValue from courses where cNo in (
        select cID from elogs where sID ='20180001' and elScore >=60
    )
    )as A where sumValue<10) ;

表就不发出来了,将就着看叭,主要是表我找不到了是哪一个了。

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄