可以把要查询的类别放到一个临时表里,如temp表,字段仍为lbbh。
select * from t1 where exists (select 'X' from temp where temp.lbbh=t1.lbbh)

解决方案 »

  1.   

    很奇怪的么;我测试了下就算有空用in也一样能查出来;
    你的语句没问题;你再试试这样呢
    select * from t1 where lbbh in (002,003,004,009)
      

  2.   

    select * from t1 where lbbh = '002'
    union all
    select * from t1 where lbbh = '003'
    union all
    select * from t1 where lbbh = '004'
    union all
    select * from t1 where lbbh = '009'
    可以使用索引
      

  3.   

    简单问题搞这么复杂
    select * from t1 
    where lbbh ='002' or lbbh ='003' or lbbh ='004' or lbbh ='009' 
    谁说用OR不能使用索引!!!!自已试试就知道了,如果没有用到索引,请检查看你的其它条件是否有限制了,注意不要在表达式左边写函数,如to_number('x')='002' 这样是不会用到索引的,还有什么not 、 is 、 like 都不会用索引.
      

  4.   

    不好意思,上面有个地方没写清,用LIKE 时用 'xx%' 能用索引, '%xx%'不能用索引
      

  5.   

    看一下执行计划,另外,要是真想用索引,用这个测试一下:
        select /*+ index(表名 索引名)*/ from table
      

  6.   

    in 不能利用 所有
    or 可以
      

  7.   

    原来如此,难怪我用like从来没有用上过索引。