1.左连接 select a.filed1,a.filed2,b.filed1 from a (左表) left join b(右表) on a.commonfiled = b.commonfiled 查询思路:按照匹配字段(外键),b表记录与a表记录进行逐一匹配,若有n条匹配,则形成n行.若无匹配,则左表中得记录是全的,即使右表没有匹配的字段存在 2.右连接 select a.filed1,a.filed2,b.filed1 from a (左表) right join b(右表) on a.…
1.准备两个表:Student,Course,其中student.C_S_Id=Course.C_Id(即Student 表中的 C_S_Id 字段为外键列,关联的是 Course 表的 C_Id 主键列) 2.内连接(table1 inner join table2 on 条件表达式):满足on条件表达式,内连接是取满足条件表达式的两个表的交集(其中inner可以省略): select * from Student s inner join Course c on s.C_S_Id=c.C_I…