34,588
社区成员
发帖
与我相关
我的任务
分享
go
if OBJECT_ID('a')is not null
drop table a
go
create table a(
id int,
num int
)
go
insert a
select 1,2 union all
select 2,2 union all
select 3,2 union all
select 4,2
go
if OBJECT_ID('b')is not null
drop table b
go
create table b(
id int,
num int
)
go
insert b
select 1,1 union all
select 2,2 union all
select 3,3 union all
select 4,4
update a set num=b.num from b where a.id=b.id
select * from a
/*
id num
1 1
2 2
3 3
4 4
*/