GROUP_CONCAT multiple fields with a different separator

Alko picture Alko · Aug 7, 2016 · Viewed 12.5k times · Source

Is it possible to do something like:

GROUP_CONCAT(user, price SEPARATOR ', ') AS items

The result is John3.99, Mike24.99

What I need is something like:

John - 3.99, Mike - 24.99

Basically use another type of separator for price field.

Answer

Paul Spiegel picture Paul Spiegel · Aug 7, 2016
GROUP_CONCAT(CONCAT(user, ' - ', price) SEPARATOR ', ') AS items

Or just

GROUP_CONCAT(user, ' - ', price SEPARATOR ', ') AS items