一道vfP程序题 alter table order add column 总金额 N(7,2)close alluse
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/08/08 22:01:01
一道vfP程序题
alter table order add column 总金额 N(7,2)
close all
use order
go top
do while not eof()
sele sum(orderitem.数量*goods.单价) from orderitem,goods where;
orderitem.商品号=goods.商品号 and orderitem.订单号 =order.订单号;
group by 订单号 into array a
replace 总金额 with a(1)
skip
enddo
replace 总金额 with a(1) 换成update order set 总金额=a为什么不行?总金额全部是一个值?
![](http://img.wesiedu.com/upload/0/29/029ae7f96e7931eda3a394bd08bb24f5.jpg)
alter table order add column 总金额 N(7,2)
close all
use order
go top
do while not eof()
sele sum(orderitem.数量*goods.单价) from orderitem,goods where;
orderitem.商品号=goods.商品号 and orderitem.订单号 =order.订单号;
group by 订单号 into array a
replace 总金额 with a(1)
skip
enddo
replace 总金额 with a(1) 换成update order set 总金额=a为什么不行?总金额全部是一个值?
![](http://img.wesiedu.com/upload/0/29/029ae7f96e7931eda3a394bd08bb24f5.jpg)
![一道vfP程序题 alter table order add column 总金额 N(7,2)close alluse](/uploads/image/z/15904106-26-6.jpg?t=%E4%B8%80%E9%81%93vfP%E7%A8%8B%E5%BA%8F%E9%A2%98+alter+table+order+add+column+%E6%80%BB%E9%87%91%E9%A2%9D+N%287%2C2%29close+alluse)
你对update用法不是很了解
update order set 总金额=a where ...只有加入条件才能定位到那一条记录,不然就是全部记录被替换了
如果你知道订单号
update order set 总金额=a where 订单号="12345"
就可以了
update order set 总金额=a where ...只有加入条件才能定位到那一条记录,不然就是全部记录被替换了
如果你知道订单号
update order set 总金额=a where 订单号="12345"
就可以了