将前两个字符串拆分为新字段 [英] Split first two words of string into new field

查看:90
本文介绍了将前两个字符串拆分为新字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,


我无法在任何地方找到问题的答案。


我有一个名为''ADDRESS'的地址字段。我想运行更新查询,以便将地址的前两个单词拆分为名为AddressSplit的新字段。


因此,如果完整地址显示以下内容< br $>
''Ruby Cottage苏格兰爱丁堡''


我会在新的领域得到'Ruby Cottage'。


同样地,如果地址是''5 Aberdeen Way Glasgow Scotland''


我会在新的领域获得'5 Aberdeen'。


非常感谢任何帮助,更喜欢查询序列而不是VBA代码。


谢谢


Sharkiness

Morning All,

I cannot find the answer to my question anywhere.

I have an address field named ''ADDRESS''. I want to run an update query so that the first two words of the address are split into a new field named ''AddressSplit''.

Therefore if the full address showed the following

''Ruby Cottage Edinburgh Scotland''

I would get ''Ruby Cottage'' in new field.

Likewise if the address was ''5 Aberdeen Way Glasgow Scotland''

I would get ''5 Aberdeen'' in the new field.

Would be grateful of any help and would prefer a query sequence rather than VBA code.

Thanks

Sharkiness

推荐答案

就个人而言,我觉得好像一个简单的函数,再加上一个Update Query就可以轻松完成这个技巧。
Personally, I feel as though a simple Function, coupled with an Update Query will easily do the trick.
  1. 函数定义:
  1. Function Definition:
展开 | 选择 | Wrap | 行号


如果您可以假设每个单词由单个空格分隔,那么你可以使用:
If you can work on the assumption that each word is separated by a single space, then you could use :
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


如果您选择使用ADezii的方法(除非性能是数百条记录中的问题,否则没有充分的理由)然后你可能想要将第7行调整为:
If you choose to use ADezii''s approach (and there''s no good reason not to unless performance is an issue across many hundreds of records) then you may want to adjust line #7 to :
展开 | 选择 | Wrap | 行号


这篇关于将前两个字符串拆分为新字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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