Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Posts
    17

    Unanswered: Select many records into 1 comma seperated field.

    I want to pull out some information for documenting my user accounts.I want to be able to show all of the users and what companies those users have access to.

    The table which stores the company information lists it in multiple rows, so there will be many results for each user
    user -- companyid
    johnd -- 2
    johnd -- 5
    johnd -- 1

    I want to select this into one record so it will show up like this
    user -- companies
    johnd -- 2,5,1

    The only way I know how to do this would be with a sub-query that uses a cursor to loop through & dump it into one string value, and then output the string value to the field. This seems extremely inefficient for such a seemingly simple task.

    Can somebody help me out here?
    thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jul 2002
    Posts
    229
    There is no way to concatenate multiple values through pure SQL as
    far I can see.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Why would you say such a thing

    http://www.sqlteam.com/item.asp?ItemID=11021
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •