Link to home
Create AccountLog in
Avatar of Basssque
Basssque

asked on

Query all columns in a table for specific characters

Is is possible to query against an entire table in Oracle and throw the results for only the fields/columns that contain the specified criteria? For example
I want to
select *
from table
where any field in any column contains a comma, question mark, hash tag, or exclamation point
Avatar of Sean Stuber
Sean Stuber

a query like that won't be efficient but you can do it with simple concatenation of the columns and checking each character

select * from table
where col1||col2||col3||col4||col5 .... like '%,%'
or  col1||col2||col3||col4||col5 .... like '%?%'
or  col1||col2||col3||col4||col5 .... like '%#%'
or  col1||col2||col3||col4||col5 .... like '%!%'
Avatar of Basssque

ASKER

Can the where statement be consolidated?
For example, If I need to check 100 columns for 20 different like statements or want to add a field, its a lot to edit
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer