-- 多表查询
select * from student,class where student.classid = class.id
select * from 学生表,成绩表,课程表 where 学生表.id = 成绩表.s_id and 成绩表.c_id = 课程表.id and 课程表.name = "java" and score>60
-- 起别名 as+别名 as可以省略
select * from 学生表 as t1,成绩表 as t2,课程表 as t3 where t1.id = t2.s_id and t2.c_id = t3.id and t3.name = "java" and score>60
select id,name 姓名,sex as 性别,age as 年龄,classid as 班级 from student where age>20
-- 连表查询
-- 内连接 join..on..
-- 外连接
-- 左外连接 left join .. on..
-- 右外连接 right join .. on..
student join class on student.classid = class.id
select * from student left join class on student.classid = class.id
select * from student right join class on student.classid = class.id
select * from 学生表 join 成绩表 on 学生表.id = 成绩表.s_id join 课程表 on 成绩表.c_id = 课程表.id
select * from 学生表 join 成绩表 join 课程表 on 学生表.id = 成绩表.s_id and 成绩表.c_id = 课程表.id