teacher表 ID name age 1 张三 40 2 李四 42 student表 ID name teacherID 1 王五 1 2 赵六 2 你现在要查出学生的姓名和他老师的姓名 那么你现在就要联合两张表进行查询才能查出来 select a.name,b.name from student as a left join teacher as b on a.teacherid=b.id 这也就是一个简单的联合查询
1,内连接,inner join-- table A 与 table B 关联的字段数据一致 2,左连接,left join-- 以table A 关联字段数据为基准,与其A关联的table B,在A中有的显示出,没有的留空 3, 右连接,right join,与条2相反的过程
ID name age
1 张三 40
2 李四 42
student表
ID name teacherID
1 王五 1
2 赵六 2
你现在要查出学生的姓名和他老师的姓名
那么你现在就要联合两张表进行查询才能查出来
select a.name,b.name from student as a left join teacher as b on a.teacherid=b.id
这也就是一个简单的联合查询
2,左连接,left join-- 以table A 关联字段数据为基准,与其A关联的table B,在A中有的显示出,没有的留空
3, 右连接,right join,与条2相反的过程