我试着用一根线,我是“你好”。把它转换成字符,这样我就可以把它转换成ascii码,然后我再把它连接起来,但问题是我把每个字符放在不同的行中。你知道怎么把它们合并成一行吗。在他们之间没有任何东西?任何帮助都将不胜感激。
bqf10yzr1#
你想要什么 group_concat() ,不是 concat() -连同期权 separator '' .
group_concat()
concat()
separator ''
set @word = 'hello';with recursive cte as ( select @word as word, left(@word, 1) as val, 1 as idx union all select word, substring(word, idx + 1, 1), idx + 1 from cte where idx < char_length(word))select group_concat(ascii(val) order by idx separator '') ascii_word from cte
set @word = 'hello';
with recursive cte as (
select @word as word, left(@word, 1) as val, 1 as idx
union all
select word, substring(word, idx + 1, 1), idx + 1
from cte
where idx < char_length(word)
)
select group_concat(ascii(val) order by idx separator '') ascii_word from cte
1条答案
按热度按时间bqf10yzr1#
你想要什么
group_concat()
,不是concat()
-连同期权separator ''
.