Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 75471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:31:17+00:00 2026-05-10T20:31:17+00:00

I have a table, call it TBL. It has two columns,call them A and

  • 0

I have a table, call it TBL. It has two columns,call them A and B. Now in the query I require one column as A and other column should be a comma seprated list of all B’s which are against A in TBL. e.g. TBL is like this

1 Alpha

2 Beta

1 Gamma

1 Delta

Result of query should be

1 Alpha,Gamma,Delta

2 Beta

This type of thing is very easy to do with cursors in stored procedure. But I am not able to do it through MS Access, because apparently it does not support stored procedures. Is there a way to run stored procedure in MS access? or is there a way through SQL to run this type of query

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:31:17+00:00Added an answer on May 10, 2026 at 8:31 pm

    You can concatenate the records with a User Defined Function (UDF).

    The code below can be pasted ‘as is’ into a standard module. The SQL for you example would be:

    SELECT tbl.A, Concatenate('SELECT B  FROM tbl         WHERE A = ' & [A]) AS ConcA FROM tbl GROUP BY tbl.A 

    This code is by DHookom, Access MVP, and is taken from http://www.tek-tips.com/faqs.cfm?fid=4233

    Function Concatenate(pstrSQL As String, _         Optional pstrDelim As String = ', ') _             As String     'example     'tblFamily with FamID as numeric primary key     'tblFamMem with FamID, FirstName, DOB,...     'return a comma separated list of FirstNames     'for a FamID     '    John, Mary, Susan     'in a Query     '(This SQL statement assumes FamID is numeric)     '===================================     'SELECT FamID,     'Concatenate('SELECT FirstName FROM tblFamMem     '     WHERE FamID =' & [FamID]) as FirstNames     'FROM tblFamily     '===================================     '     'If the FamID is a string then the SQL would be     '===================================     'SELECT FamID,     'Concatenate('SELECT FirstName FROM tblFamMem     '     WHERE FamID =''' & [FamID] & '''') as FirstNames     'FROM tblFamily     '===================================      '======For DAO uncomment next 4 lines=======     '======     comment out ADO below    =======     'Dim db As DAO.Database     'Dim rs As DAO.Recordset     'Set db = CurrentDb     'Set rs = db.OpenRecordset(pstrSQL)      '======For ADO uncomment next two lines=====     '======     comment out DAO above     ======     Dim rs As New ADODB.Recordset     rs.Open pstrSQL, CurrentProject.Connection, _             adOpenKeyset, adLockOptimistic     Dim strConcat As String 'build return string     With rs         If Not .EOF Then             .MoveFirst             Do While Not .EOF                 strConcat = strConcat & _                     .Fields(0) & pstrDelim                 .MoveNext             Loop         End If         .Close     End With     Set rs = Nothing     '====== uncomment next line for DAO ========     'Set db = Nothing     If Len(strConcat) > 0 Then         strConcat = Left(strConcat, _             Len(strConcat) - Len(pstrDelim))     End If     Concatenate = strConcat End Function  
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 146k
  • Answers 146k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think that when writing games you can get away… May 12, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer I've determined this cannot be done, so I saved the… May 12, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer You need something like a clone method or a copy… May 12, 2026 at 9:00 am

Related Questions

I'd like to programmatically build an HtmlTable/Table in the code behind of a webservice
I have a table, let's call it a that is used in a left
I have a stored procedure that returns a valueI call it from other stored
I have a table of data from mysql rendered on page via PHP into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.