sql输入一个字符串 找出该字符串中重复的字符
时间: 2023-08-14 17:06:02 浏览: 131
假设你要查找的字符串为 `str`,可以使用以下 SQL 语句找出其中重复的字符:
```
SELECT
ch, COUNT(ch) AS count
FROM
(SELECT
SUBSTRING(str, n, 1) AS ch, n
FROM
(SELECT
@row := @row + 1 AS n
FROM
(SELECT @row := 0) r, INFORMATION_SCHEMA.COLUMNS
LIMIT LENGTH(str)) numbers) characters
GROUP BY ch
HAVING count > 1;
```
这个查询会返回一个结果集,其中包含重复的字符以及它们在字符串中出现的次数。
阅读全文