想把A表的B值改成C表D值和E表F值之和

来源:百度知道 编辑:UC知道 时间:2024/06/05 06:56:19
想把A表的B值改成C表D值和E表F值之和
并把B值的小写钱数改成大写
这个用SQL怎么表示啊

update administrator.a as a set a.sum=cast((select b from administrator.b) as int)+cast((select c from administrator.c) as int) where 条件

//a表的sum必须要为int型,b表或c表为varchar可以进行转化,但必须一致,varchar是不能进行加减的,注意考虑精度和b表c表的数字是否符合标准,可以转为双精度型

最好是采用下列方式
update administrator.a as a set a.sum=cast((select sum(b) from administrator.b where 子条件) as int)+cast((select sum(c) from administrator.c where 子条件) as int) where 条件

要改b的钱的话自己写个小程序把,把值取出来然后改了后在改回去,这样好弄得多