sqlite3_fts5 error when using punctuation

1.9k Views Asked by At

I have a question string variable that contains the word "Where is my car?"

when I try and run a select on this it crashes.

String sql = "Select * from tblHALv2001 WHERE tblHALv2001 MATCH '" + question + "'";

fts5: syntax error near "?"

If I remove the question mark from the question variable then it works. But how can I correct the statement so it doesn't crash?

1

There are 1 best solutions below

3
On

You cannot simply use any random string with FTS; MATCH expects an FTS query as its right operand.

You could use double quotes to escape the question mark, but then the tokenizer would ignore it anyway.