减去同一表中的两个字段并在MS Access 2007中提交第三个字段 [英] Subtract Two Field in Same Table And Put in 3th Filed in MS Access 2007

查看:107
本文介绍了减去同一表中的两个字段并在MS Access 2007中提交第三个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





假设我有一张名为运输的桌子



在此表中我有3个字段:a,b,c



如何减去 ab 并输入 c 字段



注意:

1-很遗憾,所有字段都有文字类型。

2-现在,这个表有大约5000条记录,我不能改变字段类型或其他任何东西,我只想更新字段c减去ab



谢谢你们

hi

suppose i have a table with name "Transport"

in this table i have 3 fields : a,b,c

how i can subtract a-b and put in c field

Note :
1- unfortunately , all fields have text type .
2- now , this table have about 5000 record and i cant change field type or anything else , and i want only update field c with subtract of a-b

thanks guys

推荐答案

将数字存储为文本是个坏主意。



你必须使用类似于的查询:

It's bad idea to store numbers as a text.

You have to use query similar to:
UPDATE Transport SET c = CLng(a)-CLng(b)





如你所见,我使用 CLng 将文本转换为长整数的函数。

注意:当该字段中存储的文本无法转换时,转换可能会失败明确转换。



如需了解更多信息,请参阅:

CLng功能 [ ^ ]

更新声明 [ ^ ]



As you can see, i use CLng function to convert text to long integer.
Note: Conversion may failed when text stored in that field cannot be explicitly converted.

For further information, please see:
CLng function[^]
UPDATE statement[^]


这篇关于减去同一表中的两个字段并在MS Access 2007中提交第三个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆