标签:暴力 多个 view 索引 targe cat count 字段 多行
id | sid |
---|---|
1 | a3,a4,a1,a2,a5 |
2 | a5,a3,a4,a2 |
3 | a5,a3,a4 |
sid_tag | sid_occurrence |
---|---|
a1 | 1 |
a2 | 2 |
a3 | 3 |
a4 | 3 |
a5 | 3 |
select substring_index( substring_index( sid , ‘,‘, id_table.help_topic_id + 1 ), ‘,‘,- 1 ) as sid_tag,count(sid) as sid_occurrence from src_t JOIN mysql.help_topic id_table on id_table.help_topic_id < (
length(src_t.sid) - length(replace(src_t.sid, ‘,‘, ‘‘)) + 1
) GROUP BY sid_tag
select tag,count(*) from(
select tag from table_name
lateral view explode(split(taglist,‘,‘)) r1 AS tag) a group by a.tag;
select * from (
SELECT concat(‘a‘,topic.help_topic_id) as sid,topic.help_topic_id AS id
FROM mysql.help_topic topic
WHERE help_topic_id IN (‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘)
) as id_table JOIN (
SELECT concat(‘b‘,topic.help_topic_id) as sid,topic.help_topic_id AS id
FROM mysql.help_topic topic
WHERE help_topic_id IN (‘1‘, ‘2‘, ‘3‘)
) as id_table2 on id_table2.id <= id_table.id
sid | id | sid | id |
---|---|---|---|
a1 | 1 | b1 | 1 |
a2 | 2 | b1 | 1 |
a2 | 2 | b2 | 2 |
a3 | 3 | b1 | 1 |
a3 | 3 | b2 | 2 |
a3 | 3 | b3 | 3 |
a4 | 4 | b1 | 1 |
a4 | 4 | b2 | 2 |
a4 | 4 | b3 | 3 |
a5 | 5 | b1 | 1 |
a5 | 5 | b2 | 2 |
a5 | 5 | b3 | 3 |
标签:暴力 多个 view 索引 targe cat count 字段 多行
原文地址:https://www.cnblogs.com/suanec/p/13187736.html