Oracle
 sql >> Database >  >> RDS >> Oracle

query Oracle con diverse condizioni di filtro

Potresti comprimerlo (un po') con:

SELECT *                                       --- irrelevant to the question:
FROM table1 JOIN table2                        --- use the explicit JOIN syntax
             ON table1.id1 = table2.id2        --- not the implicit join with the
---table1,table2 where table1.id1 = table2.id2 --- WHERE syntax (removed)
WHERE
--- filters
  AND (table1.col2, table2.col2) IN
        (  ('value_11', 'value_21'),
           ('value_12', 'value_22'),
           ('value_13', 'value_23'),
           ...
           (value_1100, value_2200)
        ) 

Se hai queste condizioni di filtro in una tabella, puoi persino farlo:

  AND (table1.col2, table2.col2) IN
        (  SELECT filter1, filter2
           FROM filter_table
        )