对于我会做的like
搜索 -
select name,"term1" as searchterm from articles where name like "%term1%"
union
select name,"term2" as searchterm from articles where name like "%term2%"`
我如何获得使用的术语在使用全文搜索的OR
搜索中获得该特定结果?
有没有办法像这样做 -
SELECT name,searchterm FROM articles WHERE MATCH (name)
AGAINST ('term1 term2' IN BOOLEAN MODE);
答案 0 :(得分:1)
尝试这个(它在本地及其工作中进行了测试):
SELECT
tmp1.msg,
tmp2.tag_name
FROM (
SELECT
CONVERT(name USING utf8) as msg
FROM
`articles`
WHERE
MATCH(`name`) AGAINST ('term1 term2' IN BOOLEAN MODE)
) as tmp1
INNER JOIN (
SELECT CONVERT('term1' USING utf8) as tag_name
UNION
SELECT CONVERT('term2' USING utf8) as tag_name
) as tmp2
ON tmp1.msg LIKE CONCAT('%',tmp2.tag_name,'%')