我对sqlite上的FTS有疑问。
创建表格:
CREATE VIRTUAL TABLE mail USING fts3(subject, body);
插入演示数据
INSERT INTO mail(docid, subject, body)
VALUES(1, 'software feedback' 'found it too slow');
INSERT INTO mail(docid, subject, body)
VALUES(2, 'software feedback', 'no feedback');
INSERT INTO mail(docid, subject, body)
VALUES(3, 'slow lunch order', 'was a software problem');
搜索查询代码
SELECT *
FROM mail
WHERE subject MATCH 'software*'; ==> Selects rows 1 and 2
SELECT * FROM mail WHERE body MATCH 'feedback'; ==> Selects row 2
SELECT * FROM mail WHERE mail MATCH 'software*'; ==> Selects rows 1, 2 and 3
SELECT * FROM mail WHERE mail MATCH 'slow'; ==> Selects rows 1 and 3
但是,当我想在一个单词中搜索文本时。例如:我想搜索包含字符的任何单词" o":
前:
SELECT *
FROM mail
WHERE mail MATCH 'o';
我没有结果......
任何人都可以帮助我吗?
答案 0 :(得分:0)
您是否考虑过使用LIKE
运营商?如果您想要mail
表格中mail
字段中包含一个或多个o
个字母的记录,您可以试试这个:
SELECT * FROM mail WHERE mail LIKE '%o%';