请问我想在一个有几十万记录的表中 选出上百条指定的记录
不用in语句 怎么写 可以简洁高效?

解决方案 »

  1.   

    请用数据举例,in 、exists 
      

  2.   

    in ('asdf','qwer','cvb'……) 这种
     
    用in 效率太慢了 有什么办法解决
      

  3.   

    1、这类数据是否有规则,比如是从table中where type = 'XXX'得到的。
    'asdf','qwer','cvb'……2、用in 效率太慢了您说的是指什么?
    人工输入'asdf','qwer','cvb'……太耗时还是表查询返回结果很耗时呢
      

  4.   

    这个是php执行后得出的字符串
    不是查询结果
      

  5.   

    不了解'asdf','qwer','cvb'不是通过查询返回结果得到的?效率慢是指什么?
      

  6.   

    创建个临时表,然后做JOIN比如创建临时表 create table tmp(col varchar(10) primary key)然后再 select * from table1, tmp using (col)
      

  7.   

    或者直接用select * from table1 where col='asdf'
    union all
    select * from table1 where col='qwer'
    ...
      

  8.   

    1。 直接使用 IN (38068,238833,308799 ... )
    2。 将 (38068,238833,308799 ... ) 放入临时表,然后用 JOIN
    3。 直接在程序中 执行多个 select * where id = 38068; select * from where id=238833; ...
    4。 使用 inner join (select 38068 union all select 238833 union all ... )http://topic.csdn.net/u/20090626/16/65f043cf-b9d9-4707-b660-9857461177f4.html?70266看看这个帖子吧