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
Oracle DatabaseSQL

Avatar of undefined
Last Comment
Sean Stuber
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
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo