

-- 内连接 (Inner Join):只连接匹配的行
select * from test1 inner join test2 on test1.id = test2.id

--左外连接 (Left Jion):包含左边表的全部行(不管右边的表中是否存在与它们匹配的行),以及右边表中全部匹配的行
select * from test1 left join test2 on test1.id = test2.id

--右外连接 (Rigt Jion):包含右边表的全部行(不管左边的表中是否存在与它们匹配的行),以及左边表中全部匹配的行
select * from test1 right join test2 on test1.id = test2.id

本文深入解析了SQL中的三种连接类型:内连接、左外连接与右外连接,详细阐述了每种连接的工作原理、语法结构以及应用场景。
431

被折叠的 条评论
为什么被折叠?



