I am pulling data using python, from an ORACLE table. I can pull the rows I need for one of the lists using
office_list = [aaa, aab, aac, aad]
&& the actual list is much longer
""" SELECT * FROM ( SELECT distinct(id) as id, office, cym, type FROM oracle1.table1 WHERE office IN ({0}) ) """.format("'" + "','".join([str(i) for i in office_list]) + "'")
What I can’t figure out is how to also include another filter from a different list.
In this case it is a list of types
type_list = [type1, type2, type3, type4]
Any help would be appreciated. thanks
Advertisement
Answer
"""select * from( select distinct(id) as id, office, cym, type from oracle1.table1 where office in ({0}) and type in ({1}) ) """.format("'" + "','".join(office_list) + "'", "'" + "','".join(type_list) + "'")