34,590
社区成员
发帖
与我相关
我的任务
分享
create table table1
(
s_id int not null,
s_numberA int null
)
insert into table1 values(1,80)
insert into table1 values(2,75)
insert into table1 values(4,90)
create table table2
(
s_id int not null,
s_numberB int null
)
insert into table2 values (1,60)
insert into table2 values(3,70)
insert into table2 values (4,80)
insert into table2 values (5,45)
insert into table2 values(6,82)
select t2.s_id ,isnull(t1.s_numberA,0),t2.s_numberB table2 t2,table1 t1 where t1.s_id =t2.s_id
SELECT
ISNULL(A.s_id,B.s_id) AS s_id,
ISNULL(A.s_numberA,0) AS s_numberA,
ISNULL(B.s_numberB,0) AS s_numberB
FROM table1 AS A
FULL JOIN table2 AS B
ON A.s_id=B.s_id