If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > [Mysql] concatenate Columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-22-06, 08:21
labigre labigre is offline
Registered User
 
Join Date: Jun 2004
Posts: 17
[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
Reply With Quote
  #2 (permalink)  
Old 09-22-06, 09:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-22-06, 09:45
labigre labigre is offline
Registered User
 
Join Date: Jun 2004
Posts: 17
Thnx a lot r937. It works fine !

Cya

Labigre
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On