select * from a as a where a.id in (1,2,3,...,100)效率如何
in里面的东西是没有规律的
是从另一个表按条件select出来的是单这么写效率好,还是select * from a as a inner join b as b on b.xx=xx and a.xx=b.xx效率好

解决方案 »

  1.   

    select * from a as a where a.id in (1,2,3,...,100)select * from a as a where a.id=1;
    select * from a as a where a.id=2;
    .....
    select * from a as a where a.id=99;
    select * from a as a where a.id=100;上面肯定比下面的效率好,对吧
      

  2.   

    不一定。http://topic.csdn.net/u/20090626/16/65f043cf-b9d9-4707-b660-9857461177f4.html
    [求证&散分]MySQL   中   where   id   in   (1,2,3,4,...)   的效率问题讨论
      

  3.   

    恩,貌似没有人来个一锤定音的答案
    看了那个帖子,感觉是数据量很小||数据量很大的时候,in的效率会好
    但是不知道这个度是多少小于10条能否认为in的效率好
      

  4.   

    如果这样,为什么不直接用JOIN查询?