SQL的表的连接Left Join / Right Join /inner join相关

2022-12-08,,,,

Left Join / Right Join /inner join相关

关于左连接和右连接总结性的一句话:

左连接where只影向右表,右连接where只影响左表。

Left Join

select * from tbl1 Left Join tbl2 where tbl1.ID = tbl2.ID

左连接后的检索结果是显示tbl1的所有数据和tbl2中满足where 条件的数据。

简言之 Left Join影响到的是右边的表

Right Join

select * from tbl1 Right Join tbl2 where tbl1.ID = tbl2.ID

检索结果是tbl2的所有数据和tbl1中满足where 条件的数据。

简言之 Right Join影响到的是左边的表。

inner join

select * FROM tbl1 INNER JOIN tbl2 ON tbl1.ID = tbl2.ID

功能和 select * from tbl1,tbl2 where tbl1.id=tbl2.id相同

SQL的表的连接Left Join / Right Join /inner join相关的相关教程结束。

《SQL的表的连接Left Join / Right Join /inner join相关.doc》

下载本文的Word格式文档,以方便收藏与打印。