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 > How to concatenate?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-04, 22:27
nsarbeswar nsarbeswar is offline
Registered User
 
Join Date: Feb 2004
Location: Hong Kong
Posts: 15
How to concatenate?

Hello dears,

For example, I have a table contains records as follows:
table1
ID Name Remark
1001 Sam M1234
1001 Sam N1234
1001 Sam O1234
1002 Rita X1234
1002 Rita Y1234
1002 Rita Z1234

The output I want is as follows:
select id, remark from table1 group by id

ID Remark
1001 M1234N1234O1234
1002 X1234Y1234Z1234

Anybody can help how to build a select statement to concatenate text of different records?

Thanks
Sarbeswar
Reply With Quote
  #2 (permalink)  
Old 09-09-04, 03:03
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
in 4.1+ you can use the GROUP_CONCAT function

otherwise you have to write a script to loop over the result set
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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