Home  >  Article  >  Database  >  sqlserver 内连接左连接,右连接,全连接

sqlserver 内连接左连接,右连接,全连接

WBOY
WBOYOriginal
2016-06-07 15:51:541382browse

内连接inner join (第1种写法)select a.Name,b.Name from t_Table1 a join t_Table2 b on a.ID=b.ID (第2种写法)select a.Name b.Name from t_Table1 a inner join t_Table2 b on a.ID=b.ID 两表之间的左连接(右连接完全是简单的举一反三,所以就不写了)

内连接inner join

(第1种写法)select a.Name,b.Name from t_Table1 a join t_Table2 b on a.ID=b.ID

(第2种写法)select a.Name b.Name from t_Table1 a inner join t_Table2 b on a.ID=b.ID

两表之间的左连接(右连接完全是简单的举一反三,所以就不写了)

select a.Name,b.Name from t_table1 a left join t_table b on a.ID=b.ID

4表之间的左连接(t_Table1 既需要左关联t_Table2,又同时需要左关联t_Table3,t_Table4无用)

select a.Name,b.Name,c.Name 

from t_Table1 a left join t_Table2 b on a.ID=b.ID left join  t_Table3 c  on a.ID=c.ID,

t_table4 d

where a.ID=d.ID

等连接

select a.Name,b.Name from t_Table1 a,t_Table b

where a.ID=b.ID

全连接(Full join)

select a.Name,b.Name from t_table1 a full join t_Table2 b on a.ID=b.ID


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn