我想在sqlite3中运行LIKE查询,并安全地转义用户的输入.基本上,我想做这样的事情:
char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE '%?%'";
sqlite3_stmt* statement;
sqlite3_prepare_v2( database, query, -1, &statement, NULL );
Run Code Online (Sandbox Code Playgroud)
但是?在LIKE表达式中不受尊重.有人知道怎么做吗?
char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE '%' || ? || '%'";
Run Code Online (Sandbox Code Playgroud)
但我建议您考虑使用FTS3进行全文搜索,因为您的查询运行速度比使用强力查询快几百倍LIKE.