mysql数据库向ascii添加整数

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


大家好,所以我想把一个字符串转换成ascii码,我必须把它分成字符,然后把每个字符转换成ascii码,最后再把它们合并起来。我想在将每个ascii字符合并到一起之前,为它们添加一些常量值。有人能帮我怎么做吗?任何帮助都将不胜感激。谢谢您

ffvjumwh

ffvjumwh1#

只需在内部进行计算 group_concat() :

  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) + @add order by idx separator '') ascii_word from cte

相关问题