On 18 Nov 2010, at 1:22pm, Joseph Garry wrote:

>> From: itandet...@mvps.org
>> Joseph Garry <josephga...@hotmail.com> wrote:
>>> I'd like to set up a compiled sqllite (sqlite3_prepare_v2) statement with a 
>>> query like
>>> 'select tabid, col1, col2 from table where tabid in (?)'
>>> But how do I bind in the parameter here? An example would be welcome, of 
>>> course.
>> You can't do that directly. One way is to create a temp table, like this:
>> create temp table TabIdList (tabid integer);
>> Now you can prepare this statement:
>> select tabid, col1, col2 from myTable where tabid in (select tabid from 
>> TabIdList);
>> Populate TabIdList with your list of IDs (you can use a prepared statement 
>> for this, too, along the lines of "insert into TabIdList(tabid) values (?); 
>> ").

> That would work, but the thing I'm after here is speed. And I can't imagine 
> what you're suggesting would be very fast. Am I mistaken?

Put an index on the 'tabid' field of myTable and it'll be pretty fast.

(PS: I fixed the text order of your reply.)

sqlite-users mailing list

Reply via email to