Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    17

    Unanswered: [Mysql] concatenate Columns

    hey all,


    I' ve an sql pb on Mysql database. i need to concatenate 2 varchar column.

    The table looks like :

    Field Type Collation Attributes Null
    -------------------------------------------------------
    appli varchar(30) utf8_general_ci No
    boom varchar(5) utf8_general_ci No
    critical varchar(3) utf8_general_ci No
    perim varchar(40) utf8_general_ci No


    i need ton concatenate "Appli" & "boom" columns.

    examlple of values for thoses column:

    Col1: Col2
    ---------------
    toTo tata

    and i want to get :

    Col1:
    --------
    toto,tata

    can anyone tell me how to do that ?

    i already tried the following syntax but the reslut is a Numeric field :/ with the Value "0".


    SELECT (tb_applis.appli + "," + tb_applis.boom) AS Boom
    FROM tb_applis, tb_serveurs t2
    WHERE tb_applis.appli = t2.applis


    Ty

    Labigre

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the plus sign is used for addition

    concatenation is achieved with the CONCAT function

    if you wish to insert a comma, you might like the CONCAT_WS function instead (although this is usually used when there are more than two items being concatenated)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2004
    Posts
    17
    Thnx a lot r937. It works fine !

    Cya

    Labigre

Posting Permissions

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