Passing a list of parameters as input to a SQL query

I have a SQL query that I want to execute on a list of input parameters.

SELECT Field1, Field2
FROM Table
WHERE Field3 = ?
AND Field4 = ?

      

I have ~ 10,000 pairs of values ​​for which I want to run this query. For now, I am iterating over the list and adding each result to a dataframe. I feel like there is probably a more pythonic way to do this. I just don't know what it is.

Is there a cleaner way to do this?

+3


source to share


1 answer


I think you need to create a temporary table that stores 10,000 pairs of values. Then you can use Inner Join

in this temporary table.

Example:



Select f1,f2 
From 
    table t 
    Inner Join temptable m 
        On m.c1 = t.f3 and m.c2(column 2) = t.f4

      

+1


source







All Articles