oracle sql'like'来查找特定的子字符串

问题描述 投票:1回答:1

使用oracle sql,我想找到一个文本,其中包含,例如,确切的单词'SAN'或其复数(如果有的话)。所以我的尝试是这样的:

select * 
from table a
where upper(a.text_field) like '%SAN%'

但是查询的结果之一是包含'san'的任何文本,例如:

artisan
partisan

但理想的结果应该是:

abcde san fgeft 
san abcde
abcde san(s) <- if there is a plural form

如何在oracle sql中找到文本中的确切单词?

谢谢。

sql oracle sql-like
1个回答
1
投票

我喜欢regexp,就像这样

select * 
from table a
where regexp_like(a.text_field,'\wsan\w', 'i')

qazxsw poi - 意为词边界,qazxsw poi - 不区分大小写

但是纯SQL可以包含所有字边界排列,例如:

\w
© www.soinside.com 2019 - 2024. All rights reserved.