学习目标 www.quzixueba.com去自学吧系统教程之Mysql小白入门教程 1、select练习
总练习 新建一个老师表(teacher),字段如下:id,年级(grade),语文老师(yw_teacher),数学老师(sx_teacher) 插入如下字段数据: 1,1,王强,王丽 2,2,张强,张丽 获取如下数据: 王强老师教的学生里语文成绩最好的人 SELECT yw_teacher, teacher.grade, students.name,yw_cj FROM teacher LEFT JOIN students ON students.grade = teacher.grade LEFT JOIN students_cj ON students_cj.name = students.nameWHERE yw_teacher = '王强' ORDER BY yw_cj DESC limit 1
总练习 张丽老师教的学生各年龄人数分布 select age,count(name) as num from teacher left join students on students.grade=teacher.grade where sx_teacher='张丽' group by age Join可以多个join子句以: left join …. left join …
谢谢观看 PPT下载:www.quzixueba.com 自学QQ群:551890900