Help retrieving data

  • Hi

    I have a table that returns the next:

    ID     MATCHES                                           

    ------ --------------------------------------------------

    17     Group1

    18     Group1

    18     Group2

    18     Group3

    20     Group1

    20     Group2

    20     Group6

    19     Group1

    19     Group2

    19     Group6

    13     Group1

    13     Group4

     

    The result I need is the next:

    ID     MATCHES                                           

    ------ --------------------------------------------------

    17     Group1

    18     Group1, Group2, Group3

    20     Group1, Group2, Group6

    19     Group1, Group2, Group6

    13     Group1, Group4

    Anybody can help me?

     

     

  • basically you need to build a temp table and populate column A with your ID list.  You will then need to LOOP (any way you prefer) and start with the 1st item and write into a TEMP TABLE or @TABLE VAR the MATCHES AND THEN... LOOP through that table to concatenate a string which you would UPDATE the 1st TEMP table column B....



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Or, you can re-use what has already been posted here:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=5&messageid=99869

    Regards,

    Goce.

  • http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks a lot everybody

    Your tips was very very helpful

    Now I can smile again

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply