以下查询在Android上不起作用并引发以下异常
Unable to use function MATCH in the requested context
这是一个非常复杂的查询,所以我正在研究简化它的方法。有关信息,此查询使用sqlite-jdbc-3.715
驱动程序
SELECT * FROM stop_times WHERE
departure_time >= 1000-125
AND
departure_time <= 1000+180
AND stop_id IN
(SELECT _id FROM stop_sequences WHERE stop_ids MATCH '"642," OR "642," OR ",642"')
AND _id IN
(SELECT _id FROM trips WHERE service_id IN (SELECT _id FROM calendar WHERE wednesday=1))
ORDER BY departure_time ASC
我认为我的FTS表声明没问题:
CREATE VIRTUAL TABLE stop_sequences USING fts4(
_id INTEGER PRIMARY KEY,
stop_ids TEXT
);
SQL大师可以帮助我吗?感谢
编辑:我发现即使是最简单的查询,例如
SELECT _id FROM stop_sequences WHERE stop_ids MATCH '"642";
失败并出现同样的错误。我已经在我的代码中的其他地方的另一个数据库上使用MATCH
语句,它根本没有抱怨。错误消息中提到的上下文是否与Android的Context
?
答案 0 :(得分:1)
创建此表时,您指定了USING fts4(),对吧?如果没有,那么全文查询根本不起作用。
答案 1 :(得分:0)
您可以尝试使用union
更改查询SELECT * FROM stop_times WHERE
departure_time >= 1000-125
AND
departure_time <= 1000+180
AND stop_id IN
(SELECT _id FROM stop_sequences
WHERE stop_ids
MATCH '"642,"'
UNION
SELECT _id FROM stop_sequences
WHERE stop_ids
MATCH '",642"'
)
AND _id IN
(SELECT _id FROM trips WHERE service_id IN (SELECT _id FROM calendar WHERE wednesday=1))
ORDER BY departure_time ASC