首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

update ,值从另外一个表查询,该怎么解决

2012-04-01 
update ,值从另外一个表查询update gh_ghzdk set ghrq(select ghrq from test where test.blhgh_ghzdk.b

update ,值从另外一个表查询
update gh_ghzdk set ghrq=(select ghrq from test where test.blh=gh_ghzdk.blh)

出错信息:
服务器: 消息 512,级别 16,状态 1,行 3
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
语句已终止。


请问该怎么写

[解决办法]
update gh_ghzdk set ghrq=a.ghrq from test a where a.blh=gh_ghzdk.blh)
[解决办法]
update A
set A.ghrq = B.ghrq
from gh_ghzdk A,test B
where B.blh=A.blh

热点排行