how to "group" multiple rows into one field?

Discussion in 'Databases' started by falcondriver, Oct 22, 2007.

  1. #1
    hiya,

    i have a table "pictures", and a table "tags". every picture can have 0 or x tags.
    how can i group the tags, so that they all appear comma-separated in one field in my result set? CONCAT_WS() might be helpfull at some point...

    table looks like this:

    pictures:
    --------
    -id
    -name
    -path
    -...

    tags:
    -----
    -id
    -name
    -pic_id (link to pictures.id)
     
    falcondriver, Oct 22, 2007 IP
  2. mbnaragund

    mbnaragund Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To concatenate two column with ‘,’ operator:

    update table_name set Result_Column =column1||','||column2

    For your Ex: update table_name set Result_Column =pictures||','||tags
     
    mbnaragund, Oct 23, 2007 IP