Reputation: 120
How do I prefix a string to a field before GROUP_CONCAT
this
id test_id 1 4 2 4 2 5 3 5 1 5 1 6
to
id test_id 1 id_4,id_5,id_6 2 id_4,id_5 3 id_5
I want id_ prefixed to the test_id before I can get it by GROUP_CONCAT in MySQL
Upvotes: 2
Views: 2928
Reputation: 160943
SELECT
id,
GROUP_CONCAT(CONCAT('id_', test_id))
FROM
your_table
GROUP BY id
Upvotes: 9
Reputation: 32148
You need to use:
SELECT GROUP_CONCAT(CONCAT('id_', test_id)) FROM ....
Upvotes: 2