看不懂,我要的是select * from tb where ( a like 'aaa%' or a like 'bbb%' or a like 'c%' or...)
把where条件合成一句写,其中or的条件由一个字符串组成

解决方案 »

  1.   

    select * from TB where substr(col_a,1,3) in ('aaa', 'bbb', 'ccc', '...')
      

  2.   

    就是说取col_a的前面三位,在('aaa', 'bbb', 'ccc', '...')
    德都符合要求
      

  3.   

    如果你想用一条sql来解决,恐怕是不行了,因为你连条件都不知道,sql怎么来写?
    除非你在程序中去拼'aaa', 'bbb', 'ccc', '...',然后再sql中以串变量来代替,
    这个时候语句可以是这样:
    select * from tb where col_a in condition;
    这里面的condition就是一个串  ('aaa', 'bbb', 'ccc', '...'),包含括号的一个串。
      

  4.   

    语句中忘记加函数了
    select * from tb where substr(col_a,1,3) in condition;
      

  5.   

    写一个循环,动态生成条件,再组合成一条SQL
      

  6.   

    select * from (select tb.*, substr(col_a, 1, 1) a, substr(col_a, 2, 1) b,
                    substr(col_a, 3, 1) c from tb) t
    where t.a=t.b and t.b=t.c and t.a>='a' and t.a<='z'