While working on the SQL stuff in the last blogpost, I had the problem, that my GROUP_CONCAT
ignored my SEPARATOR ' '
and I had no clue why. What does one do in this moment? Ask the colleagues and the community.
Wrong:
GROUP_CONCAT(DISTINCT(o.sales_channel_id) SEPARATOR ' ')

Sorry for the german screenshot, but from time to time I’m lazy and prefer my mother tongue.
It is a screenshot from slack and I asked what the problem with my GROUP_CONCAT
is, because the IDs are just merged together without any space in between. Björn Meyer mentioned Robin Homberg and he wrote, that it might be the problem, that GROUP_CONCAT
doesn’t work well with binary fields and better explicitly run the id through HEX
and it worked ?
Right:
GROUP_CONCAT(DISTINCT(HEX(o.sales_channel_id)) SEPARATOR ' ')
The discussion ends with me telling Robin, that I’ll blog about it and mention him if it is ok – it was, so: Thanks Robin! And thanks Björn for telling him <3
One thought on “MySQL: GROUP_CONCAT and binary fields”