如何在ORACLE SQL where子句中的多列中搜索多个字符串

时间:2022-08-24 19:46:53

My situation - I have to two tables with several columns each, and I need to find certain strings in certain columns in those two tables. For example the search string could be 'ExampleString1' , 'ExampleString2%' etc around 20 strings and about 5 - 6 columns in each table.

我的情况 - 我必须有两个表,每个表有几列,我需要在这两个表的某些列中找到某些字符串。例如,搜索字符串可以是“ExampleString1”,“ExampleString2%”等,大约20个字符串,每个表大约5-6列。

I m using the following to find atleast one string in the multiple columns, but this even is not working.

我使用以下内容在多列中找到至少一个字符串,但这甚至不起作用。

select * from table1 a where upper('ExampleString1%') in (a.Column1, a.column2, a.column3) 

Although I can do some basic sql queries, I m not that acquaint with sql. I like to know the solution or any material I can study to get to solution.

虽然我可以做一些基本的SQL查询,但我不熟悉sql。我想知道解决方案或我可以研究的任何材料以获得解决方案。

Thanks rK

谢谢你

1 个解决方案

#1


3  

You can combine all required fields and run a check on that:

您可以组合所有必填字段并对其进行检查:

select * 
from table1 a
where NVL(upper(a.Column1),'')||NVL(upper(a.column2),'')||NVL(upper(a.column3),'') like upper('ExampleString1%')

#1


3  

You can combine all required fields and run a check on that:

您可以组合所有必填字段并对其进行检查:

select * 
from table1 a
where NVL(upper(a.Column1),'')||NVL(upper(a.column2),'')||NVL(upper(a.column3),'') like upper('ExampleString1%')