--临时表
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)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有