How to FTS-match from 2 different columns

905 Views Asked by At

I am trying to search 2 separate columns called keyword and keyword2 for a match. Can this be done with SQLite FTS?

I've tried this statement but it did not work:

String sql = "Select * from tblvHAL2001 WHERE tblvHAL2001 MATCH 'keyword:" + question + "' OR MATCH 'keyword2:" + question +"'";
2

There are 2 best solutions below

1
On BEST ANSWER

You should use only a single FTS query per table. FTS does have boolean operators:

... WHERE tblvHAL2001 MATCH 'keyword: "blah" OR keyword2: "blah"'

And in FTS5, a single column filter can specify multiple columns:

... WHERE tblvHAL2001 MATCH '{keyword keyword2}: "blah"'
0
On
WHERE tblvHAL2001 MATCH '{keyword keyword2}: "blah"'