Home > database >  Mysql string GROUP_CONCAT joining together of the time, how to specify a delimiter for line breaks?
Mysql string GROUP_CONCAT joining together of the time, how to specify a delimiter for line breaks?

Time:09-17

The select GROUP_CONCAT (p_str SEPARATOR '; ')
The from (select the 'aa' as p_str
The from dual
Union all
Select the 'bb' as p_str
The from dual) mt;

Behind the semicolon here replaced by a newline char (13), direct replacement is an error, there are other way?

CodePudding user response:

Try this, I am here not MYSQL environment, don't know the MYSQL HEX (13) is a newline, you can give it a try,
: HEX () function returns a string representation of the HEX value form, note: is not a decimal into hexadecimal number, but into a string,,,
UNHEX () function: each pair of hexadecimal digits into one character at a time,

The select GROUP_CONCAT (p_str SEPARATOR HEX (13))
The from (select the 'aa' as p_str
The from dual
Union all
Select the 'bb' as p_str
The from dual) mt;

CodePudding user response:

And I use char (13) at fault, but similar syntax in oracle can use listagg (CRH (13))

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 'HEX (13))
The from (select the 'aa' as p_str
The from dual
The union al 'at line 1

CodePudding user response:

GROUP_CONCAT (p_str SEPARATOR '\ n')
  • Related