ms-access中有一个group_concat函数吗? [英] is there a group_concat function in ms-access?

查看:153
本文介绍了ms-access中有一个group_concat函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ms-access中是否存在group_concat函数或类似的功能?

is there a group_concat function in ms-access or something similar?

推荐答案

您应该问自己是否需要通用解决方案(

You should ask yourself if you need a generic solution (another is by Allen Browne) or if you need it just for the present purpose. If you really only need it this once, do it the easy way.

另一方面,在VBA代码中连接列表时,请利用长期的Access专家Trevor Best教给我的技巧,那就是将分隔符放在每个值的开头,然后使用Mid()剥离它.而不是在子记录中循环:

On a side note, when concatenating lists in VBA code, take advantage of a trick taught to me by long-time Access guru Trevor Best, and that's to stick the delimiter at the beginning of every value and then use Mid() to strip it off. Instead of this inside your loop through the child records:

  If Len(strOutput) = 0 Then
     strOutput = NewValue
  Else
     strOutput = strOutput & ", " & NewValue
  End If

...在循环中使用它:

...use this inside the loop:

  strOutput = strOutput & ", " & NewValue

...,然后退出循环时,请去除前导定界符:

...and then when you exit the loop, strip off the leading delimiter:

  strOutput = Mid(strOutput, 3)

这对整个地方都有影响,并简化了在整个上下文中串联的代码.

This has implications all over the place and simplifies code for concatenation in a whole host of contexts.

这篇关于ms-access中有一个group_concat函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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