[英]Match the end half of an expersion to only letters SQL ORACLE
I've got a column of data in an SQL table and after a first pass it contains only data starting with 'BVH' and 'BVG'. 我在SQL表中有一列数据,并且在第一次传递之后,它仅包含以'BVH'和'BVG'开头的数据。 I want it to only contain data that has 3 numeric characters after this and no more letters.
我希望它仅包含此后具有3个数字字符且没有更多字母的数据。 I have tried
我努力了
OUC not like 'BVG%[a-z]%' and OUC not like 'BVH%[a-z]%'
as I don't know if the letters are going to fall in the first, second or third (or multiple) positions following the first 3 letters. 因为我不知道字母是否会落在前三个字母之后的第一,第二或第三(或多个)位置。 I also can't know exactly what letters are going to appear
我也不知道到底会出现什么字母
Example data 示例数据
BVH122
BVH174
BVH336
BVH123
BVH447
BVH447
BVH321
BVH573
BVG1NS
BVG1T2
BVH283
BVH172
BVG12T
BVG1T2
Is that what you need? 那是你需要的吗?
with dat as (select 'BVH122' a from dual
union all select 'BVH174' a from dual
union all select 'BVG1NS' a from dual
union all select 'BVH172' a from dual
union all select 'BVG12T' a from dual
)
select * from dat where regexp_like(a,'[A-Z]{3}[0-9]{3}');
So your query is: 因此,您的查询是:
select * from table where regexp_like(OUC,'BV[GH]{1}[0-9]{3}');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.