Such a variable parameter is, in SQL-context, normally called a 'placeholder', and denoted by '?'.
DBD::SQLite manual on Placeholders
UPDATE: After more careful reading I realize you are looking for the SQL IN construct: select .... where value1 in ('apple', 'pie') In this case I don't think you can use a placeholder to represent the possibly multiple values inside the IN(), i.e., you need separate sql statements for separate numbers of ? as IN() parameters.
As DBI docs say: "placeholders can only represent single scalar values".
(In PostgreSQL this problem can be avoided by (standard SQL): WHERE value1 = ANY ( ? ) or (postgres-specific SQL): WHERE array[value1] <@ ( ? ) which you can then execute, passing in an arrayref for the (single!) placeholder. Both forms are indexable and fast (in a quick 1GB test table with a rowcount of 10M (retrieving 20 rows) takes less than 1 ms). SQLite does not know how to do this (I actually tried but alas ...)) so you are reduced to constructing SQL-statements dependent on the size of the search-set (see other replies). )
In reply to Re: dbi:SQLite multiple query
by erix
in thread dbi:SQLite multiple query
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |