如何获得最佳搜索结果AND,OR,LIKE

时间:2010-03-04 23:09:02

标签: sql select search sql-like

查询#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%'

等...

返回不同的结果

1 个答案:

答案 0 :(得分:4)

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