gpt4 book ai didi

mysql - SQL - MATCH 显示每一行

转载 作者:行者123 更新时间:2023-11-30 00:33:53 24 4
gpt4 key购买 nike

我不确定这里出了什么问题,但此查询显示了该用户的“about”和“articles”中的每个条目。我使用了随机关键字进行搜索,以确保只给出一个结果,但同样的事情发生了。

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 fiddle 问题http://sqlfiddle.com/#!2/e963d/1

最佳答案

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'

关于mysql - SQL - MATCH 显示每一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22324263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com