MySQL数据库:子查询的应用

子查询

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

# 子查询的用法
# 在字段
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) ;

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

相关文章
相关标签/搜索