sql server 更新两个表的某个字段

来源:互联网 发布:linux 字符编码转换 编辑:程序博客网 时间:2024/05/18 16:38
--临时表create table tmp_cup(    a varchar(20),    b varchar(50),    c varchar(20))select * from t_customer--//更新简称字列update t_customer  set SHORTNAME=(select shortname from tmp_cup where a=custid)不过如此的话, 如果子查询的某个查询返回多条数据的话就有可能报错:消息 512,级别 16,状态 1,第 1 行子查询返回的值不止一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。所以,如果要求许可的话最好在子查询里添一个:district即:update t_customer  set SHORTNAME=(select district shortname from tmp_cup where a=custid)

0 0