"Andrea Galeazzi" <galea...@korg.it> wrote in message news:49b6557c.3060...@korg.it > I'm developing an application which relies on sqllite as back-end. > Now I face to this problem: I've got a form that allows the user to > fill a lot of fields, obliviously only a little part of them will > actually be filled, the others isn't gonna be in the search criteria. > So I prepare a parameterized query containing the whole possible > fields like this: SELECT * FROM Song WHERE id = ? AND title = ? AND > album LIKE '%?%'; How can I bind the unrequested fields?
You can't. Perhaps surprisingly, NULL=NULL is always false. To test a field for NULL, you must write "title IS NULL". Or, if you don't need to distinguish between, say, NULL and an empty string, you could write "coalesce(title, '') = ?" and bind an empty string to the parameter. Also, '%?%' is a string literal consisting of three characters, one of which is '?'. There is no parameter placeholder there. You need to write '%' || ? || '%' Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users