In SQLite3, how can I do SQL escaping in a LIKE clause?

I would like to run a LIKE query in sqlite3 with a safe user deletion. 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 if inside the LIKE clause. Does anyone know how to do this?

+4
source share
1 answer
 char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE '%' || ? || '%'"; 

But I recommend that you study FTS3 for full-text search, because your queries will run hundreds of times faster, force LIKE .

+6
source

All Articles