【问题标题】:how to get best search results AND , OR , LIKE如何获得最佳搜索结果 AND , OR , LIKE
【发布时间】:2010-03-04 23:09:01
【问题描述】:

查询 #1:


SELECT DISTINCT `title`
FROM `table`
WHERE (
`title` LIKE '%this is search%'
)
OR (
`title` LIKE '%this%'
AND `title` LIKE '%is%'
AND `title` LIKE '%search%'
)
OR (
`title` LIKE '%this%'
OR `title` LIKE '%is%'
OR `title` LIKE '%search%'
)
LIMIT 0 , 10

但效果不佳,当我尝试拆分此 sql 时:

查询 #2:


SELECT DISTINCT `title`
    FROM `table`
    WHERE (
    `title
` LIKE '%this is search%'
    )

查询 #3:


SELECT DISTINCT `title`
    FROM `table`
    WHERE (
`title` LIKE '%this%'
    AND `title` LIKE '%is%'
    AND `title` LIKE '%search%'

等...

返回不同的结果

【问题讨论】:

  • 您的实际问题是什么?请详细说明。
  • 我的问题是如何在没有全文搜索的情况下获得最佳搜索结果
  • 最佳搜索结果是指与搜索最相似还是返回的结果最多?我也对你在这里想要什么感到困惑。
  • 是的,你想要一个精确的字符串匹配,它必须包含所有单词,还是在多单词搜索中单个单词匹配就足够了?使用自然语言搜索具有提供分数列的好处,因此按相关性排序更简单

标签: sql select search sql-like


【解决方案1】:

您提供的信息太少,但据我所知,您正在寻找 mySQL 的 fulltext search 函数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    相关资源
    最近更新 更多