我需要使用一个公共键从多个表中获取 MATCH AGAINST 分数并将它们的总和组合起来。最终的目标是创建一个搜索算法,该算法将返回具有匹配 group_ID 的行。我已经构建了一个 mysql 查询,该查询尚未运行且没有错误。
如果您想知道,这是特定的错误:
警告:mysql_fetch_array():提供的参数不是有效的 MySQL 结果资源
这些是我要搜索的表:
表:jn_groups
group_ID,名称
表:jn_chat
聊天 ID、群组 ID、姓名
表:jn_events
event_ID、group_ID、标题、描述
我当前的查询如下所示:
SELECT
g.group_ID AS group_ID,
g.name AS name,
SUM(gscore + cscore + escore) AS score,
MATCH(g.name) AGAINST (" . $query . "') AS gscore,
MATCH(c.name) AGAINST (" . $query . "') AS cscore,
MATCH(e.title,e.description) AGAINST (" . $query . "') AS escore
FROM jn_groups g
LEFT JOIN jn_chat c ON g.group_ID = c.group_ID
LEFT JOIN jn_events e ON g.group_ID = e.group_ID
WHERE
MATCH(g.name) AGAINST (" . $query . "')
OR MATCH(c.name) AGAINST (" . $query . "')
OR MATCH(e.title,e.description) AGAINST (" . $query . "')
ORDER BY score
任何帮助进行类似于该运行的查询将不胜感激!