Concatenate data from more than 1 row?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Concatenate data from more than 1 row?

  1. #1
    Join Date
    Nov 2001
    Posts
    13

    Concatenate data from more than 1 row?

    Hi Peers,

    Wonder if you can help? I need a query that can concatenate data from more than one row and only return a single value.

    Scenario: Our application splits long text (for example the list of Fields in a form) into chunks, with each chunk be saved in a separate row. The field list for a form called 'Main' that contains "First_Field, Second_Field, Third_Field" is split and becomes (in simplified terms)

    Form ID Fields
    ==== == ======
    Main 01 First_Field, Se
    Main 02 cond_Field, Thi
    Main 03 rd_Field
    aaaa 01 etc...
    aaaa 02 etc..
    zzzz 01 etc...
    zzzz 02 etc..
    zzzz 03 etc.
    zzzz 04 etc

    A simple query to find occurences of Form that contain 'Second_Field' fail becuase that value is split. What i'd like to do is concatenate the 3 (or more/less) values back together into a single string and use it for comparison in a where clause.

    I've heard that DECODE might help, but my knowledge of it is limited, hence the cry for help.

    Thanks in advance

    Ben

  2. #2
    Join Date
    Mar 2002
    Posts
    200
    You can use explicit cursors, contactenate them in each iteration of the Loop. What say? I am afraid whether DECODE can help to do this in a single SELECT statement.

  3. #3
    Join Date
    Sep 2001
    Location
    Düsseldorf, Germany.
    Posts
    588
    This will help you.. but it has some limitations on number of records to be concatenated

    http://www.dbasupport.com/forums/sho...threadid=29975

Posting Permissions

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



Click Here to Expand Forum to Full Width