赞
踩
一、(having,group by,select嵌套放在select里)
可参考 https://www.jianshu.com/p/8b135d373df1
二、(not in,distinct去重,select嵌套放在where里)
表的内容如下:
实现功能:查询没学过"张三"老师授课的同学的信息
实现语句:
SELECT student.s_id,student.s_name FROM student WHERE s_id
not in (SELECT distinct( score.s_id) FROM score,course,teacher WHERE score.c_id=course.
c_id AND course.t_id=teacher.t_id AND teacher.t_name='张三');
三,(select嵌套放在from里)表可参照2
实现功能:查询学过编号为"01"并且也学过编号为"02"的课程的同学的信息
实现语句:
SELECT *from (SELECT s_id,s_score from score WHERE score.c_id
="01")as t1,(SELECT s_id,s_score from score WHERE score.c_id="02")
as t2 WHERE t1.s_id=t2.s_id
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。