mysql将多行合并成一行

92dk7w1h  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(446)

我试着用一根线,我是“你好”。把它转换成字符,这样我就可以把它转换成ascii码,然后我再把它连接起来,但问题是我把每个字符放在不同的行中。你知道怎么把它们合并成一行吗。在他们之间没有任何东西?任何帮助都将不胜感激。

bqf10yzr

bqf10yzr1#

你想要什么 group_concat() ,不是 concat() -连同期权 separator '' .

  1. set @word = 'hello';
  2. with recursive cte as (
  3. select @word as word, left(@word, 1) as val, 1 as idx
  4. union all
  5. select word, substring(word, idx + 1, 1), idx + 1
  6. from cte
  7. where idx < char_length(word)
  8. )
  9. select group_concat(ascii(val) order by idx separator '') ascii_word from cte

相关问题