当前位置:Gxlcms > 数据库问题 > mysql in 子查询 效率慢,对比

mysql in 子查询 效率慢,对比

时间:2021-07-01 10:21:17 帮助过:13人阅读

SELECT id,detail,groupId from hs_knowledge_point where groupId in ( SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 UNION all SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 ) UNION ALL SELECT id,detail,groupId from hs_knowledge_point_commit where groupId in ( SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 UNION all SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 ) View Code 技术分享
SELECT id,detail,groupId from hs_knowledge_point where groupId in (
    select groupId from (
        SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 
        UNION all
        SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 
    ) tmp
)
UNION ALL
SELECT id,detail,groupId from hs_knowledge_point_commit where groupId in (
    select groupId from (
        SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 
        UNION all
        SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 
    ) tmp
)
View Code

 

技术分享

技术分享

 

 

技术分享

技术分享

 

mysql in 子查询 效率慢,对比

标签:com   技术   sed   closed   where   gif   commit   ima   select   

人气教程排行