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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.