Smile.Hunter
Smile.Hunter

Reputation: 252

MySQL query: merge result of many rows into 1 row

I want to use MySQL query to merge result of many rows into 1 row by appending next record to the first one until the end of result, is it possible? I do not want to use any other application to process this task, any SQL geeks here?

Upvotes: 0

Views: 369

Answers (2)

Sashi Kant
Sashi Kant

Reputation: 13465

TRY GROUP_CONCAT

Select 

GROUP_CONCAT(column SEPARATOR ',')
from myTABLE
GROUP BY PKCOlumn

Upvotes: 2

mvp
mvp

Reputation: 116068

You probably need to use SELECT with GROUP BY clause together with some aggregate function.

If you want to concatenate strings into one, appropriate aggregate function is group_concat().

Upvotes: 1

Related Questions