在sql中搜索基于模式

时间:2013-10-28 06:24:39

标签: sql oracle10g

我有专栏employee_no varchar2(6)。我想获取所有employee_no 010101121212232323等所有记录。如何根据此模式进行搜索?

2 个答案:

答案 0 :(得分:1)

您是否正在寻找一组数字重复的员工编号? 如果是这样,那么您可以使用REGEXP_LIKE。

select *
from yourtable
where regexp_like(employeeno, '(..)\1\1');

分解正则表达式,

(..)  --matches any two characters
\1    --matches the first group(the one in brackets)
\1    --matches the first group(the one in brackets)

Demo

答案 1 :(得分:0)

select * from yourtable where emp_no like '%010101%' OR emp_no like '%121212%' OR 
emp_no like '%232323%'