1 回答
TA贡献1155条经验 获得超0个赞
对于#2,您只需要以下组合:
WHERE MATCH(words) AGAINST('keyword1 keyword2 ... keywordN' IN BOOLEAN MODE)
AND NOT MATCH(words) AGAINST('+keyword1 +keyword2 ... +keywordN IN BOOLEAN MODE)
这将返回至少有一个关键字但不是全部的行。还是我误解了你的问题?
架构 (MySQL v8.0)
create table test (
id int not null auto_increment primary key,
words text not null,
FULLTEXT idx (words)
);
insert into test(words)
values('Arc Book Cow Dog'), ('Book Cow Fox'), ('Arc Book Cow Fox'), ('Book Cow');
查询 #1
SELECT *
FROM test
WHERE MATCH(words) AGAINST('Arc Fox' IN BOOLEAN MODE)
AND NOT MATCH(words) AGAINST('+ARC +Fox' IN BOOLEAN MODE)
ORDER BY id;
| id | words |
| --- | ---------------- |
| 1 | Arc Book Cow Dog |
| 2 | Book Cow Fox |
- 1 回答
- 0 关注
- 100 浏览
添加回答
举报