MySQL SELECT all in one big chain (columns and rows)

advertisements

I have a big MySQL SELECT query, that I need to convert into one string only, so I can make an UPDATE out of it, without having to use two separate querys. For the sake of simplicity, let's assume we have a SELECT query that returns this result:

How do I convert all of it into something like this :

1,Bob,20;2,Adam,30;3,Steve,40;

That I can use to UPDATE some other table with ?

Knowing that both the number of columns and rows can change and are not static. (very important ! Especially the columns!). How can I pull this off ? I don't think CONCAT() can help in this situation.

Any help would be appreciated. Thanky ou.


Can you try this?

SELECT group_concat(concat(id, ',', name, ',', age) separator ';')
FROM test

http://www.sqlfiddle.com/#!2/915557/9