且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server 中左连接和右连接的区别

更新时间:2023-01-20 15:33:21

Select * from Table1 left join Table2 ...

Select * from Table2 right join Table1 ...

确实是完全可以互换的.但是尝试Table2 left join Table1(或它的相同对,Table1 right join Table2)以查看差异.这个查询应该给你更多的行,因为 Table2 包含一个 id 在 Table1 中不存在的行.

are indeed completely interchangeable. Try however Table2 left join Table1 (or its identical pair, Table1 right join Table2) to see a difference. This query should give you more rows, since Table2 contains a row with an id which is not present in Table1.