New Member needs assistance

  • Hello all, I have found this website in need of a little assistance. I am not as familiar with SQL Server 2005 but I need to know if a such query is possible. I do not have any issues with this in MySQL, but I know the two are different.

    Basically I need to know if I can pass a list in a where statement such as this.

    select *

    from table1

    where (column1, column2) in (valuea, value1)

    Here is what I need to be able to do, I just can not find a way as of yet.

    I want to be able to query multiple possibilities of valuea and valueb in column1 and column2. Here is what I could use if I just wanted to use a single value for each:

    select *

    from table1

    where column1 = valuea

    and column2 = value1

    I have tried this but does not return the expected results

    select * from table1

    where column1 in (valuea, valueb, valuec)

    and column2 in (value1, value2, value3)

    What this returns is anything in column1 that has a match for column2. I need the exact match as I supply in the query.

    Any thoughts would be helpful!

    Thanks

  • Unless I'm missing something here, have you tried "or-ing" the results?

     


    Td Wilson

  • can you give sample data and sample expected results.

    i think IN {list} should do the trick unless if you did not specify your requirement fully.


    Everything you can imagine is real.

  • Try this

    select *

    from table1

    where column1 in(value_a, value_b)

    UNION

    select *

    from table1

    where column2 in(value_a, value_b)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply