I'm looking to find all occurrences of "Dr. Jones
" in a name field using regexp_like. I can do the OR (all names with DR or JONES in it) but I need both names to be present in the field.
我希望使用regexp_like在名称字段中查找所有出现的“Dr. Jones”。我可以做OR(其中包含DR或JONES的所有名称),但我需要在该字段中存在两个名称。
Is there a simple way to do this with regexp_like without using multiple statements?
有没有一种简单的方法可以使用regexp_like而不使用多个语句?
I'm looking for a shortcut way. The answer below gives it in an easy situation. I know I can have:
我正在寻找一种快捷方式。下面的答案给出了一个简单的情况。我知道我可以:
where regexp_like(color_code,'red|blue|green','i');
and it will give me any record of color_code with either of those three names in it. What I'm looking for is something like:
它会给我任何color_code的记录,其中包含这三个名字中的任何一个。我正在寻找的是:
where regexp_like(color_code,'red&blue&green','i');
that would only select records with ALL THREE colors in the name but they can be in any order so: red blue green, green purple blue black red, yellow red orange green blue
只会选择名称中包含所有三种颜色的记录,但它们可以按任意顺序排列:红蓝绿,绿紫蓝黑红,黄红橙橙蓝
would all make the list
都会列出清单
1 个解决方案
#1
select * from mytable
where regexp_like(txt,'(Dr.+Jones+)|(Jones.+Dr+)','i');
ok took away the need for period after dr and allowed the words to be switched
确定了博士后需要一段时间,并允许切换的话
#1
select * from mytable
where regexp_like(txt,'(Dr.+Jones+)|(Jones.+Dr+)','i');
ok took away the need for period after dr and allowed the words to be switched
确定了博士后需要一段时间,并允许切换的话