日期:2014-05-16  浏览次数:20745 次

请教一个多关键字查询问题
例如有三条数据 : 1. 中国银行
  2. 中国中信银行
  3. 中信银行
输入两个关键字 中国 中信 查询出来的结果是
   
  1. 中国中信银行
  2. 中国银行
  3. 中信银行 

用oracle怎么写

------解决方案--------------------
select * from table_name where col_name like '%中国%'or col_name like '%中信%';

------解决方案--------------------
SQL code

--输入两个关键字做模糊查询是把
--以下用到的table1为测试表
--name为测试表中存储银行名称的列
select distinct name from table1 where name like '%中国%' or '%中信%'

------解决方案--------------------
SQL code

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

------解决方案--------------------
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
------------ 
中国中信
中国银行
中信银行