如何完全使用sql语句根据一个表的内容update另一个表(100分)

  • 主题发起人 henryczh
  • 开始时间
H

henryczh

Unregistered / Unconfirmed
GUEST, unregistred user!
在sql server7中建数据库demo1,有
表a 字段:no num1 num2 num3 other
表b 字段:index_num num1 num2 num3
表a中no,other已事先录入,现想update表a如下:
update a
set num1=b.num1,num2=b.num2,num3=b.num3
where b.index_num=22 and no='NO111';
但在query analyzer中运行报错:
The column prefix 'b' does not match with a table name or alias name used in the query.
 
update a
set num1=b.num1,num2=b.num2,num3=b.num3
from a,b
where b.index_num=22 and no='NO111'
 
update a
set num1=b.num1,num2=b.num2,num3=b.num3
from a,b
where b.index_num=22
and a.no=b.index_num
and a.no='NO111'
 
谢谢二位兄弟,先到的多给分:)。
 
顶部