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?
To do this, open your query in design mode. Enter your field names in the query window separated by the & symbol. This query will return the concatenation of the FirstName field , a space character, and the [LastName] field. The results will be displayed in a column called Expr1.
When you want to combine the values in two or more text fields in Access, you create an expression that uses the ampersand (&) operator. For example, suppose that you have a form that is called Employees.
Click the "Arrange" tab, and then click the "Merge" button in the Merge/Split group to merge your selected fields into one.
You create an inner join by dragging a field from one data source to a field on another data source. Access displays a line between the two fields to show that a join has been created. The names of the tables from which records are combined. The names of the fields that are joined.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With