I am writing code in Python, and I have a list of id's: [14503, 14504, 14505, ...]
And I would like to write a SQL query to query a database, specifically the following very basic table
id val
14501 0
14502 1
14504 0
....
The table consists of a bunch of id's (I'm not sure if they are unique), and val
, which is either a 0 or 1.
For my list of id's I would like to write a query that returns any id that has a val = 1
- is this possible?
I suppose the difficult part for me is incorporating the list of Python id's, as there are several hundred thousand of them.
Otherwise the SQL code is trivial:
SELECT id from sval where val=1