Symonds
Symonds

Reputation: 194

search value in the entire table oracle sql

I have table test_d which has 30 columns and i want to search for specific string value 'ARFTU' to check in which column does this value exists and i want to get entire row.

As i dont want to use below sql to check each and every columns to see if the value exists, Is there any other way to write sql which checks the entire columns in table and search for specific value ?

SELECT * from test_d
WHERE name ='ARFTU'

Upvotes: 0

Views: 524

Answers (2)

SELECT * FROM test_d WHERE 'ARFTU' IN (col1, col2, ...., col30);

Upvotes: 0

J M
J M

Reputation: 1

If all of your columns have compatible data types and you just want to return any rows that have at least one column that matches your value here is one way to accomplish that:

SELECT *
FROM test_d
WHERE 'ARFTU' IN (col1, col2, ... coln);

check

Upvotes: 1

Related Questions