如何仅从文本字段中选择数字 [英] How to select only numbers from a text field
本文介绍了如何仅从文本字段中选择数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何仅从字段中提取数字并将该值放入其自己的字段中?
How can I pull only the number from a field and put that value into its own field?
例如,如果field1包含值"Name(1234U)".
For example, if a field1 contains a value of "Name(1234U)".
我需要一种SQL或VBA方式来扫描该字段并将其取出.因此field2等于"1234".
I need an SQL or VBA way to scan that field and pull the number out. So field2 will equal "1234".
有什么想法吗?
推荐答案
此方案或变体可能适合:
It is possible that this or a variation may suit:
SELECT t.Field1, Mid([Field1],InStr([field1],"(")+1,4) AS Stripped
FROM TheTable As t
例如:
UPDATE TheTable AS t SET [field2] = Mid([Field1],InStr([field1],"(")+1,4);
编辑评论
如果该字段以u)
结尾,即字母括号,您可以说:
If the field ends u)
, that is, alpha bracket, you can say:
UPDATE TheTable AS t SET [field2] =
Mid([Field1],InStr([field1],"(")+1,Len(Mid([Field1],InStr([field1],"(")))-3)
这篇关于如何仅从文本字段中选择数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文