SELECT
count(id) AS counts ,TITLE,
CODE,
chaifen
FROM
(
SELECT
t.CODE,
t.TITLE,
t.ID,
substring_index(
substring_index(
t.CODE,
';',
b.help_topic_id + 1
),
';',
- 1
) AS chaifen
FROM
ude.tableName t
JOIN mysql.help_topic b ON b.help_topic_id < (
LENGTH(t.code) - LENGTH(REPLACE(t.code, ';', '')) + 1
)
) AS newtable
GROUP BY
chaifen
count(id) AS counts ,TITLE,
CODE,
chaifen
FROM
(
SELECT
t.CODE,
t.TITLE,
t.ID,
substring_index(
substring_index(
t.CODE,
';',
b.help_topic_id + 1
),
';',
- 1
) AS chaifen
FROM
ude.tableName t
JOIN mysql.help_topic b ON b.help_topic_id < (
LENGTH(t.code) - LENGTH(REPLACE(t.code, ';', '')) + 1
)
) AS newtable
GROUP BY
chaifen
本文介绍了一种复杂的SQL查询方法,通过使用子查询和连接操作从特定表格中获取并分组数据。该查询统计了不同分类的数量,并展示了如何处理包含分号分隔的字符串字段。
645

被折叠的 条评论
为什么被折叠?



