Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL In Clause Multiple Columns

SELECT *
FROM Tabl tabb
WHERE (tabb.col1, tabb.col2) IN ( (1,2), (3,4))

The above works in Oracle but I am trying to run in a proprietary SQL engine which doesn't support the above query formation with multiple columns in IN.

I am trying to find combinations of 1,2 and 3,4 in the DB.

Please help me with any alternatives for achieving the above.

I am looking for ways to pass a list of values for col1 and col2 from Java at one shot, so '=' might not be an option as it might require two SQL statements for achieving the above.

like image 411
user1857647 Avatar asked Nov 27 '12 19:11

user1857647


1 Answers

How about this?

SELECT
    *
FROM
    Tabl tabb
WHERE
    (tabb.col1 = 1 AND tabb.col2 = 2) OR
    (tabb.col1 = 3 AND tabb.col2 = 4)
like image 129
hall.stephenk Avatar answered Sep 28 '22 12:09

hall.stephenk