954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Search in several columns for string?

Hi everyone,
I am new to this board. I am trying to figure out how to set up an SQL statement to grab a record from a database when I'm not sure what column/field the string I am looking for will be in. for instance:
I am looking for "ABCDEFG", but it could be in column1 or column2 or column3.

Thanks!

Deanna

DeannaF829
Newbie Poster
2 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

Create a view based on concatenated value of all the columns and run the search on that view instead of the table.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

I don't understand. I need to know how to write the SQL statement.

DeannaF829
Newbie Poster
2 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

try to create a view like this

create view view_name as select col || col2 || col3 as concat_column from table_name


and run the search on the concat_column of view_name.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: