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:
SELECT DISTINCT `title`
FROM `table`
WHERE (
`title
` LIKE '%this is search%'
)
或
SELECT DISTINCT `title`
FROM `table`
WHERE (
`title` LIKE '%this%'
AND `title` LIKE '%is%'
AND `title` LIKE '%search%'
或等...
返回不同的结果
答案 0 :(得分:4)
您提供的信息太少,但从我所看到的,您正在寻找mySQL的fulltext search函数。
Boolean full-text searches允许您使用+
和-
Natural language searches与单词列表匹配,并返回加权结果集。