update 更新表中字段的值,语句如下。。

chenlishu413 2006-04-23 08:44:13
update 表1 set totalsum=(select val(total)*val(price) from 表1)

我想求出表中totalsum的值,这个值是由数量(total)*件数(price) 总是出错,我是用access数据库的真不知道是怎么回事,请各位朋友指点。。。
...全文
259 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xeqtr1982 2006-04-23
  • 打赏
  • 举报
回复
update 表1 set totalsum=val(total)*val(price)

--这样呢?
hyrongg 2006-04-23
  • 打赏
  • 举报
回复
Sorry no access envirement ,this query run in SQL 2005 it's ok

create table #t(id int identity(1,1),total int,price int,totalsum int)
insert into #t select 10,5,null
union all select 15,5,null
--select * from #t

update #t set totalsum=total*price
select * from #t
drop table #t
----------------------------
1 10 5 50
2 15 5 75

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧