select * from a where fa like '%DL%';

解决方案 »

  1.   

    晕!
    要查fa='DL'的干嘛要'DL8'来判断???
    直接用select * from a where fa='DL';不就行了?!是不是楼主没描述清楚?
      

  2.   

    在查询之前并不知道条件中是包含'DL'的,所以不能直接用fa='DL'
      

  3.   

    select * from a where fa=substr('DL8',1,2);
      

  4.   

    假设你的变量名为v_str
    v_str中可能包含'DL8'也可能不包含,
    如果包含的话就查出fa='DL'的数据来,对不?select * from a where fa='DL' and 
    exists(select 1 from dual where instr(v_str,'DL8')>0);
      

  5.   

    heyixiang(子豚の愛人) 的方法是可以,实际上我想表达的是fa字段的值是条件中的子字符串,所以substr('DL8',1,2)只是一个特例,并不能涵盖所有的情况
      

  6.   

    不好意思,搞大了,只需:select * from a where fa='DL' and instr(v_str,'DL8')>0;
      

  7.   

    select * from a  where instr('dl8',fa)>0;
      

  8.   

    感谢njhart2003() ,这样写就可以了select * from a where instr('DL1',fa)>0;
      

  9.   

    友情提示:
    如果fa上建索引的话
    select * from a where instr('DL1',fa)>0;
    性能不如:
    select * from a where fa='DL' and instr(v_str,'DL8')>0;......