查找字符串SQL中的特定值



我需要在字符串中搜索可能出现在其中任何位置(包括开头)的特定值。它本身必须是精确匹配的

select * from LeadTimeNodes where ParentCombination like '%293 %'

所以我需要在ParentCombination字段中找到293作为它自己的实体。

字段中字符串的一些例子:

'3293 >>> 671' should not find anything as 293 is part of a bigger number 3293
'293' should find it as it is on its own
'479 >>> 12930' should not find anything as 293 is part of 12930
'6000 >>> 293' should find it
'293 >>> 1600' should find it

如果我使用上面的示例代码,它将空格合并到搜索中,并在后面的数字中工作,但如果我在它前面放一个空格'% 293 %',那么它将无法找到以293

开头的字符串。希望这有意义。

我选了James的Like;或者组合溶液。也许不是最有说服力的,但它确实奏效了。由于

Oracle:

select REGEXP_Replace('3293 >>> 671', '(.*) >>> (.*)', '1') as first_param,
REGEXP_Replace('3293 >>> 671', '(.*) >>> (.*)', '2') as second_param
from dual;

这个给你输出作为两个单独的值。然后,您可以将其封装在另一个具有精确字符串匹配的select中。

最新更新