views:

37

answers:

2

I need to use group_concat to build a list of comma separated values but I need the values to be quoted. How do I do this?

This:

425,254,431,53,513,13,1,13

Should be converted to:

'425','254','431','53','513','13','1','13'
+2  A: 

You can quote the elements before applying GROUP_CONCAT.

SELECT   GROUP_CONCAT(CONCAT('\'', some_column, '\''))
FROM     some_table
Max Shawabkeh
+1: You were first
OMG Ponies
Thanks Max, I was trying to decide who to credit for this. Thaks so much!
jim
+1  A: 

Use:

GROUP_CONCAT(CONCAT('''', your_column, '''' ))
OMG Ponies
Thanks OMG Ponies. This works like a charm.
jim