码迷,mamicode.com
首页 > 数据库 > 详细

mysql in 子查询 效率慢,对比

时间:2017-08-07 20:31:46      阅读:182      评论:0      收藏:0      [点我收藏+]

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

技术分享
 desc 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   

原文地址:http://www.cnblogs.com/shixm/p/7300937.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!