现有两张表A和B,要把表A中字段Bid等于表B中字段Id的数据查出,并把表A中的字段Name值更新成表B中的字段Name值
create table A
(
Id int identity(1,1) not null,
Bid int not null,
Name varchar(20) null
)
create table B
(
Id int identity(1,1) not null,
Name varchar(20) null
)
SQL语句:
update A set Name=B.Name from B where A.Bid=B.Id