Navaneeth.K.N <navaneet...@gmail.com> wrote: > I am trying to use parameters in a LIKE query. I have the following > code which uses Sqlite C/C++ API. > > const char *sql = "SELECT word FROM words WHERE word LIKE ?1 || '%' > ORDER BY freq DESC LIMIT 10;"; > > int rc = sqlite3_prepare_v2 (db, sql, -1, &stmt, NULL); > if ( rc != SQLITE_OK ) > return false; > > sqlite3_bind_text ( stmt, 1, data , -1, NULL ); > > Unfortunaltly, this won't work.
It should. Check the value of "data" variable - you are probably passing something other than what you think you are. I don't think anything wrong with the code you've shown - the problem must lie in the code you haven't. > When I execute > the same statement after removing parameters it works perfectly. > Something like, > > const char *sql = "SELECT word FROM words WHERE word LIKE 'word'%' > ORDER BY freq DESC LIMIT 10;"; That can't be right - there's an extra apostrophe before % sign. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users