Mysql 数据库将整数添加到 ascii

Mysql Database adding an integer to ascii

大家好,所以我想把一个字符串转换成ascii码,我不得不把它拆分成char,然后将每个char转换成ascii,然后在最后合并它们。我想在将它们重新合并之前为每个 ascii 字符添加一些常量值。有人可以帮助我该怎么做吗?任何帮助将不胜感激。谢谢

只需在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