Darren Duncan <[EMAIL PROTECTED]> wrote: > > Alternately, and probably more elegantly, > > SELECT name FROM people WHERE name LIKE '%' || ? || '%' >
Yes, it is mome elegant. Unfortunately, SQLite is stupid and does not optimize this well. It computes the concatenation once per row instead of once for the whole query. This is really something I should fix. When I was first writing the expression code generator, I thought about doing constant folding but thought "No - who ever type in SQL expressions that contain foldable constants". That was a reasonable assumption then - because at that time there where no parameters. But now with parameters, one can see a compelling reason to do constant folding. There are other things ahead of this on queue (such as getting 3.3.x to work and incorporating the wince port). So until I get to this, your work-around is to put the constant expression in a subquery: SELECT name FROM people WHERE name LIKE (SELECT '%' || ? || '%'); -- D. Richard Hipp <[EMAIL PROTECTED]>