Tim Johnson wrote:
I would like to construct a query that searces on a variable list of
primary keys.
Example: Lkeys = [12, 23, 15, 17]## python - style list of integers
Select column from table where ID in Lkeys; ## mysql statement?
Is this possible, or does one have to generate a query for each key or
generate a query with multiple ORs?
MySQL supports the IN operator, you can write:
Select column from table where ID in (12, 23, 15, 17)
In Python this could be done like this:
Lkeys = [12, 23, 15, 17]
res = query('Select column from table where ID in (%s)' %
(','.join(map(str,Lkeys
--
Roger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]