Create table A(ID int ,col1 varchar(20)) Create table B(ID int ,col2 varchar(20)) insert into A select 1,'AAA' union all select 2,'BBB' union all select 3,'CCC'insert into B select 1,'A' union all select 4,'B' union all select 5,'C'select A.*,B.* from A left join B on A.ID=B.IDdrop table A drop table B
Create table B(ID int ,col2 varchar(20))
insert into A
select 1,'AAA'
union all
select 2,'BBB'
union all
select 3,'CCC'insert into B
select 1,'A'
union all
select 4,'B'
union all
select 5,'C'select A.*,B.*
from A left join B on A.ID=B.IDdrop table A
drop table B