MySQL数据库:子查询的应用

子查询

子查询是一种常用计算机语言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) ;

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

posted @ 2019-11-21 23:09  软二的小忠晏  阅读(287)  评论(0编辑  收藏  举报