Concatentate data from a query into a single row (Transpose)

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

Let’s say you have a query that returns this

What I want is to have it return this in a query

After much searching on the topic of transpose, with some complex solutions offered, I stumbled onto the

function in Mysql.

So my query looks like this /* Show Gift Cert numbers */ ( SELECT GROUP_CONCAT(cert_id) FROM ugiftcert_history uh WHERE so.entity_id = uh.order_id GROUP BY uh.order_id ) AS gc_numbers,

Onto greatness.

Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts.