create table x
(
a int,
b varchar(20)
)
insert into x (a ,b ) values (1,'a');
insert into x (a ,b ) values (2,'b');
insert into x (a ,b ) values (3,'c');
insert into x (a ,b ) values (4,'d');
create table y
(
b int,
c varchar(20)
)
insert into y (c ) values ('a');
insert into y (c ) values ('e');
insert into y (c ) values ('c');
insert into y (c ) values ('f');
select * from x
select * from y
update y set [b] = m.a from
(select x.*,y.c from x inner join y on x.b =y.c ) m
where y.c =m.c