例如有三条数据 : 1. 中国银行
                  2. 中国中信银行
                  3. 中信银行
输入两个关键字 中国 中信  查询出来的结果是
   
   1. 中国中信银行
   2. 中国银行
   3. 中信银行 用oracle怎么写

解决方案 »

  1.   

    select * from table_name where col_name like '%中国%'or col_name like '%中信%';
      

  2.   


    --输入两个关键字做模糊查询是把
    --以下用到的table1为测试表
    --name为测试表中存储银行名称的列
    select distinct name from table1 where name like '%中国%' or '%中信%'
    //这个地方的关键字是需要你拼接上去的
    //在java里面sql的拼接方式为:
    //关键字1...s1
    String s1;
    //关键字2...s2
    String s2;
    /*
    *中间省略业务逻辑过程,这个过程即你的s1,s2的值如何来的
    */
    //得到s1,s2的值进行一个sql的拼接
    String sql="select distinct name from table1 where name like '%"+s1+"%' or '%"+s2+"%'";
    /*
    *执行sql,那么数据库里面实际运行的就是类似我最上面写的那么一条完整的查询语句,
    *只是关键字根据你的拼接不同而不同
    */
      

  3.   


    --sql写错 补充
    select distinct name from table1 where name like '%中国%' or name like '%中信%'
      

  4.   

    select * from (
    select '中国中信' as a from dual
    union all
    select '中国银行' from dual
    union all
    select '中信银行' from dual
    union all
    select 'ICBC银行' from dual
    union all
    select '农业银行' from dual
    ) where regexp_like(a,'中国[[:alpha:]]|中信[[:alpha:]]')A            
    ------------ 
    中国中信      
    中国银行      
    中信银行