I want to run LIKE queries in sqlite3 and safely escape user input. Basically, I want to do something like this:
< /p>
char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE'%?%'";
sqlite3_stmt* statement;
sqlite3_prepare_v2( database, query, -1, &statement , NULL );
But? Not respected in LIKE expressions. Does anyone know how to do it?
char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE'% '||? ||'%'";
But I suggest you consider using FTS3 for full text search, because your query runs hundreds of times faster than using brute force LIKE queries.
< /div>
I want to run a LIKE query in sqlite3 and safely escape the user’s input. Basically, I want to do something like this:
char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE'%?%'";
sqlite3_stmt* statement;
sqlite3_prepare_v2( database, query, -1, &statement, NULL );
But? Not respected in LIKE expressions. Does anyone know how to do it?
char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE'%' ||? ||'%'";< /pre>But I suggest you consider using FTS3 for full text search, because your query runs hundreds of times faster than using brute force LIKE queries.