Bug #17832 group_concat seperator parameter doesn't accept variables
Submitted: 1 Mar 2006 18:41 Modified: 5 Mar 2006 9:04
Reporter: Marques Johansson Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[1 Mar 2006 18:41] Marques Johansson
Description:
The group_concat function has a seperator option described in the documents to take "expression" as it's parameter.  When passing a user variable (and others?) as "expression" an error is generated.

How to repeat:
mysql> select 2 as t,group_concat(2 separator ':');
t,group_concat(2 separator ':')
2, NULL
1 row in set (0.02 sec)

mysql> set @a=3; select 2 as t,group_concat(2 separator @a);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@a)' at line 1
[1 Mar 2006 18:54] Marques Johansson
I'm an evil liar and a wrottin spleler.  I was not reading from the official documents when I saw "expr" as the group_concat separator parameter.  The documents clearly state 'string'.  And so I am left asking, why not an expression?

I've changed the severity to 'Feature request'.
[5 Mar 2006 9:04] Valeriy Kravchuk
Thank you for a reasonable feature request.
[3 Feb 2007 21:29] Altruist Again
Has this feature been added to 5.1?How can one over come this limitation or now, what a pity it only accepts literals!!
[27 Mar 2007 11:03] greg --
You can over this limitation by use this trick, for example :

GROUP_CONCAT(myfield,CHAR(11) SEPARATOR '') <= if you like a vertical tab separator

Bye !
[9 Mar 2012 9:33] Nicolas Pow
Hy everyone!

and what about GROUP_CONCAT(column SEPARATOR CONCAT(':',':'))

I know that GROUP_CONCAT(column SEPARATOR '::') works fine but i'm actually trying to go deeper using the CONCAT function into the GROUP_CONCAT function. 

This exemple is not really what i want to do but it reveal the problem.

i'll try to express myself better :

As it is written in the documentation CONCAT function return a string and SEPARATOR is taking a string as argument.

So, why this way doesn't work?

Is this a bug or am I wrong somewhere?

I get error code : #1064 - You have an error in your SQL syntax;
[18 Jul 2014 11:02] Aleks Aleks
So, why the problem is still not solved?
[25 Sep 2023 12:12] Jerome Dellamaria
The fact that this hasn't been looked at in the last twenty years is very weird to me. Why the difference between CONCAT and GROUP_CONCAT ?
Being obligated to use a hardcoded expression for GROUP_CONCAT is immensely limitating its usage.