gpt4 book ai didi

mysql - 使用 Match Against 进行全文搜索 - 将 BY 与工作相关性

转载 作者:行者123 更新时间:2023-11-29 12:07:26 26 4
gpt4 key购买 nike

我有以下查询,但尝试添加 ORDER BY 相关性 DESC。谁能告诉我正确的语法,因为我没有成功地将其投入使用并且没有收到匹配的结果:

$query =
"(SELECT postid as id, title as name, 'post' as type FROM post WHERE MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE))
UNION
(SELECT pdid as id, pdname as name, 'product' as type FROM product WHERE MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE))";

这是我尝试过的:

$query =
"(SELECT postid as id, title as name, 'post' as type MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE) as relevance FROM post
WHERE MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE))
UNION
(SELECT pdid as id, pdname as name, 'product' as type MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE) as relevance FROM product
WHERE MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE))
ORDER BY relevance DESC
";

最佳答案

$query =
"(SELECT postid as id, title as name, 'post' as type, MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE) as relevance FROM post
WHERE MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE))
UNION
(SELECT pdid as id, pdname as name, 'product' as type, MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE) as relevance FROM product
WHERE MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE))
ORDER BY relevance DESC
";

我发现“as type”后面缺少一个逗号。版本完成后,目前运行良好。

问题已解决并且运行良好。

关于mysql - 使用 Match Against 进行全文搜索 - 将 BY 与工作相关性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31237444/

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