tags:

views:

13

answers:

1

Hi,

The table consists of columns column_1, column_2, column_3.

Given the set of string values (string1, string2,... string 10) I have to create a query to return all rows which contain string1 or string2 or ... or string10 in column_1 or in column_2.

I would appreciate if anyone suggested a good way to write an appropriate query statement for a given problem.

At first I created a statement

"SELECT .... FROM ... WHERE column_1 = string1 OR column_2 = string1 OR column_1 = string2 OR column_2 = string2 OR ... OR column_2 = string10"

but this way the query is very long although a method could be created to compose such query.

+2  A: 
SELECT
    ...
FROM
    ...
WHERE
    column_1 in (string1, string2...string10)
    OR column_2 in (string1, string2...string10)

I noticed you said contain but you're actually testing for equality, these are 2 different things and the query is totally different you really meant contain.

devnull