update A set AID=(select BID from B where B.N=A.N) from( select * from B )B where A.N=B.N
create table A(AID int, N int, X char(1)) insert A select 1, 1, 'a' union all select 2, 2, 'b' union all select 3, 3, 'c'create table B(BID int, N int, Y char(1)) insert B select 4, 1, 'a' union all select 5, 2, 'b' union all select 6, 3, 'c'update A set AID=B.BID from( select * from B )B where A.N=B.N
谢谢楼上.update b set bid = (select a.aid from a) where a.n = b.n 我这样写,报错到我郁闷了...
from a
where a.n = b.n
from(
select * from B
)B
where A.N=B.N
create table A(AID int, N int, X char(1))
insert A select 1, 1, 'a'
union all select 2, 2, 'b'
union all select 3, 3, 'c'create table B(BID int, N int, Y char(1))
insert B select 4, 1, 'a'
union all select 5, 2, 'b'
union all select 6, 3, 'c'update A set AID=B.BID
from(
select * from B
)B
where A.N=B.N
where a.n = b.n
我这样写,报错到我郁闷了...