gpt4 book ai didi

sql - Ms Access 查询 : Concatenating Rows through a query

转载 作者:行者123 更新时间:2023-12-03 10:39:38 26 4
gpt4 key购买 nike

假设我在 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

我想通过查询来实现这一点。有人可以帮助我实现这一目标吗?

最佳答案

您需要一个函数来进行连接。

Microsoft Access condense multiple lines in a table

使用您的数据的示例:

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;

关于sql - Ms Access 查询 : Concatenating Rows through a query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5517233/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com