问题
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.
回答1:
GROUP_CONCAT(CONCAT(user, ' - ', price) SEPARATOR ', ') AS items
Or just
GROUP_CONCAT(user, ' - ', price SEPARATOR ', ') AS items
回答2:
Try this way
GROUP_CONCAT(
DISTINCT CONCAT(user,',',Price SEPERATOR)
ORDER BY items
SEPARATOR ';'
)
来源:https://stackoverflow.com/questions/38816859/group-concat-multiple-fields-with-a-different-separator