mysql - Mysql数据库将整数添加到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
推荐阅读
- python - 我很困惑为什么这不会打印我的文本文件
- java - 以另一种方法返回更新值
- algorithm - Minizinc 错误:无效的类型说明:预期的 `float',实际的 `var float'
- python - 如何在 Python 中为每个日期绘制图表
- html - 宽度和高度 100% 不适用于弹出图像
- node.js - Discord.js:TypeError:client.channels.get 不是函数
- azure-devops - 在 azure 管道中的代理池中扩展模板检查
- javascript - 为什么在执行递归回调时 .foreach 的行为与 for...of 不同?
- windows - 有没有办法在 D3D 应用程序使用 Visual Studio 2015 中调试 gpu 渲染图?
- scala - 从列中的给定列获取逗号分隔的对应值列表