我使用fts3
创建了一个表格。我使用以下查询来获得结果
String query = "SELECT "+ID+" as _id," +
NAME +
" from " + TABLENAME +
" where " + NAME + " MATCH '" + inputKeyword + "';";
Log.w(TAG, query);
其中列出了基于inputKeyword
。
但它不适用于多列,
String query = "SELECT "+ID+" as _id," +
NAME +
" from " + TABLENAME +
" where " + NAME + " MATCH '" + inputKeyword + "' AND "+ EMAILADDRESS + " MATCH '"+emailaddress+"';";
这不会给出任何结果,并且还说您无法在此查询中使用MATCH
。
怎么做?
答案 0 :(得分:1)
您的查询如下所示:
SELECT ID as _id, Name
FROM TableName
WHERE Name MATCH 'xxx' AND EmailAddress'yyy'
这缺少第二列的MATCH运算符。 你想要的应该是这样的:
SELECT ID as _id, Name
FROM TableName
WHERE TableName MATCH 'Name:xxx EmailAddress:yyy'
答案 1 :(得分:0)
显然sqlite不支持将OR查询与MATCH条件相结合。工会工作
SELECT *
FROM email_fts
WHERE "to" MATCH 'a@b.com'
UNION
SELECT *
FROM email_fts
WHERE "from" MATCH 'c@d.com'