[英]Match the end half of an expersion to only letters SQL ORACLE
我在SQL表中有一列數據,並且在第一次傳遞之后,它僅包含以'BVH'和'BVG'開頭的數據。 我希望它僅包含此后具有3個數字字符且沒有更多字母的數據。 我努力了
OUC not like 'BVG%[a-z]%' and OUC not like 'BVH%[a-z]%'
因為我不知道字母是否會落在前三個字母之后的第一,第二或第三(或多個)位置。 我也不知道到底會出現什么字母
示例數據
BVH122
BVH174
BVH336
BVH123
BVH447
BVH447
BVH321
BVH573
BVG1NS
BVG1T2
BVH283
BVH172
BVG12T
BVG1T2
那是你需要的嗎?
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}');
因此,您的查詢是:
select * from table where regexp_like(OUC,'BV[GH]{1}[0-9]{3}');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.