大家好,所以我想把一个字符串转换成ascii码,我必须把它分成字符,然后把每个字符转换成ascii码,最后再把它们合并起来。我想在将每个ascii字符合并到一起之前,为它们添加一些常量值。有人能帮我怎么做吗?任何帮助都将不胜感激。谢谢您
ffvjumwh1#
只需在内部进行计算 group_concat() :
group_concat()
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) + @add 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) + @add order by idx separator '') ascii_word from cte
1条答案
按热度按时间ffvjumwh1#
只需在内部进行计算
group_concat()
: