我不确定这里有什么问题,但是此查询显示的是"关于"和"文章"对于那个用户。我已经使用随机关键字进行搜索,尝试确保只给出一个结果,但同样的事情发生了。
mysql_query("SELECT a.about,b.title,b.article,b.description
FROM about a
JOIN articles b ON b.user_id=a.user_id
WHERE
(
MATCH(a.about) AGAINST ('$search')
OR
MATCH(b.title,b.article,b.description) AGAINST ('$search')
)
AND a.user_id='$user_id'
");
的SQL小提琴
答案 0 :(得分:0)
mysql_query("SELECT DISTINCT a.about,b.title,b.article,b.description
FROM about a
JOIN articles b ON b.user_id=a.user_id
WHERE
(
MATCH(a.about) AGAINST ('+$search' IN BOOLEAN MODE)
OR
MATCH(b.title,b.article,b.description) AGAINST ('+$search' IN BOOLEAN MODE)
)
AND a.user_id='$user_id'
");
This article可以为您提供有关以不同方式使用MATCH
的更多信息
在about和title-article-description中分开搜索
SELECT a.about,null title,null article ,null description
FROM about a
WHERE
(
MATCH(a.about) AGAINST ('BNMV' IN BOOLEAN MODE)
)
AND a.user_id='1'
UNION
select null, b.title,b.article,b.description
from articles b
where
(MATCH(b.title,b.article,b.description) AGAINST ('BNMV' IN BOOLEAN MODE))
AND b.user_id='1'