女士访问查询:通过查询连接行 [英] Ms Access Query: Concatenating Rows through a query
本文介绍了女士访问查询:通过查询连接行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我在Ms Access中有以下信息表:
ColumnA ColumnB
1 abc
1 pqr
1 xyz
2 efg
2 hij
3 asd
我的问题是,如何将第二列中的值连接到基于第一列的行值。我想要的查询结果如下:
ColumnA ColumnB
1 abc,pqr,xyz
2 efg,hij
3 asd
我想通过查询来实现这一点。有人可以帮我达到这个目的吗?
解决方案
您需要一个函数来进行连接。 b $ b
使用您的数据的示例:
选择T.ColumnA
,GetList(Select ColumnB From Table1 As T1 where T1.ColumnA =& [T]。[ColumnA],,,)AS ColumnBItems
From Table1 AS T
Group按T.ColumnA;
Suppose I have table in Ms Access with following information:
ColumnA ColumnB
1 abc
1 pqr
1 xyz
2 efg
2 hij
3 asd
My question is, how can I concatenate the values in the second column to a row value based on the first column. The query results that I want is as follows:
ColumnA ColumnB
1 abc, pqr, xyz
2 efg, hij
3 asd
I want to achieve this through a query. Can someone help me attain this?
解决方案
You need a function to do the concatenation.
Microsoft Access condense multiple lines in a table
Example using your data:
Select T.ColumnA
, GetList("Select ColumnB From Table1 As T1 Where T1.ColumnA = " & [T].[ColumnA],"",", ") AS ColumnBItems
From Table1 AS T
Group By T.ColumnA;
这篇关于女士访问查询:通过查询连接行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文