27,580
社区成员
发帖
与我相关
我的任务
分享if object_id('a')is not null drop table a
go
create table a(table_id int, zip int)
insert a select 1, 2
insert a select 2, 3
insert a select 3, 5
if object_id('b')is not null drop table b
go
create table b( table_id int, zone int)
insert b select 1 , 7
insert b select 3 , 9
insert b select 4, 10
update b set zone=zip from b inner join a on b.table_id =a.table_id
select *from b
/*table_id zone
----------- -----------
1 2
3 5
4 10*/update b
set zone=a.zip
from a
where a.table_id=b.table_idupdate b set zone=zip from b inner join a on b.table_id =a.table_id