SQL 生成连续字符
Posted 啦啦啦啦啦啦啦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL 生成连续字符相关的知识,希望对你有一定的参考价值。
WITH x AS
(SELECT 0 AS id UNION ALL
SELECT id + 1 AS id
FROM x
WHERE id < 9)
SELECT *
FROM x;
-- 生成连续字母(a-z)
WITH x AS
(SELECT 1 AS id UNION ALL
SELECT id + 1 AS id
FROM x
WHERE id < 26)
SELECT CHAR(id+96) AS id
FROM x;
-- 生成连续字符(0-9,a-z)
WITH x AS
(SELECT 0 AS id,CHAR(ascii(‘0‘)) AS cc UNION ALL
SELECT id + 1 AS id,CASE WHEN id<9 THEN CHAR(ascii(‘1‘)+id) ELSE CHAR(ascii(‘a‘)+id-9) END AS cc
FROM x
WHERE id < 35)
SELECT id, cc
FROM x;
转自:
https://blog.csdn.net/huryer/article/details/83538116
以上是关于SQL 生成连续字符的主要内容,如果未能解决你的问题,请参考以下文章