Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate records

Status
Not open for further replies.

yigalm

Technical User
Aug 16, 2001
42
US
Hi,

Is it possible to concatenate records into one?
I mean, that if I have a table of software titles, is it possible to put them all into one record?

Thank you.
 
try union Ion Filipski
1c.bmp


filipski@excite.com
 
Let me clarify what I am trying to do.

I have a table like so:

Software ID
word 55
excel 55
access 55
winzip 55
photoshop 55
powerpoint 55

And I want to put all this data into here:

ID Name E-Mail Software
55 Joe joe@joe.com word, excel, access, winzip, etc.

I don't know how many software titles each user might have.

Thank you.


 
try some workaround:

select concat(a.Software, b.Software) from
x a inner join x b on a.ID = b.ID and a.xxx != b.xxx..... Ion Filipski
1c.bmp


filipski@excite.com
 
I am new to MySQL. Probably that is why I don't understand what you mean.

What is 'a' and 'b' in the following?:
"select concat(a.Software, b.Software) from"

What is 'x' and 'xxx' in the following?:
x a inner join x b on a.ID = b.ID and a.xxx != b.xxx.....
 
I think what you want is to create another column in your existing table, and then run a query which concatenates the other software columns together into that column, right?

IonFilipski is right that you need the CONCAT function, but the a. and b. refers to concatenating columns from two different tables, which is not what you seem to want.

Try this:

1. create a "group" column on your table. I am assuming your tablename is also "Software.

2. Run this query: "UPDATE {tablename} SET group = CONCAT_WS(', ', word,excel,access,winzip,photoshop,powerpoint);"

3. Now you can drop the individual software columns, and just keep the group column (name it whatever you want).

The CONCAT_WS function is a variation of CONCAT that allows you to specify a separator for all the elements at once.

See for a better explanation of CONCAT() and the other string functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top