[英] Difference between left join and right join in SQL Server
我知道SQL Server中的连接.
例如有两张桌子表1,表2.
它们的表结构如下所示.
create table Table1 (id int, Name varchar (10))
create table Table2 (id int, Name varchar (10))
表1数据如下:
Id Name
-------------
1 A
2 B
表2数据如下:
Id Name
-------------
1 A
2 B
3 C
如果我执行下面提到的两个SQL语句,两个输出将是相同的
select *
from Table1
left join Table2 on Table1.id = Table2.id
select *
from Table2
right join Table1 on Table1.id = Table2.id
请在上面的SQL语句中解释左连接和右连接之间的区别.