On Sun, May 10, 2009 at 10:03:57PM -0400, Roy Donaldson scratched on the wall:
> SELECT rowid, colA FROM Table1; > SELECT rowid, colB FROM Table1 WHERE rowid IN (?,?,?,...) AND colA = ?; > SELECT rowid, colC,colD FROM Table1 WHERE rowid IN (?,?,?,...) AND colB = ?; > SELECT rowid, colE FROM Table1 WHERE rowid IN (?,?,?,...) AND colC = ? AND > colD = ?; > ... > > Is this possible to do with parameterized statements? Since the number of > items in the "IN" group changes for each SELECT statement (the subgroup gets > narrower and narrower), I would guess that it's not possible and as well as > defeating some of the usefulness of parameterized statements. Unfortunately, no, it isn't, for exactly the reasons you're thinking. > The only option that I've thought of is to use string concatenation so that > I would end up with something like this: > > string subgroup = "('1', '2', '3')"; > string sqlQuery = "SELECT rowid, colB FROM Table1 WHERE rowid IN " + > subgroup + " AND colA = ?; > > Any other suggestions? Depending on your environment, temp tables can work very well for this kind of thing. Have the IN( ) do a subselect and use the table as your array. Of course, you can't parametrize the table name, so you might still end up building statements more often than you wish. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users