MySql多个关键字like查询结果按照匹配最多排序:


SELECT * FROM table WHERE
`title` LIKE '%关键字1%' OR `title` LIKE '%关键字2%' OR `title` LIKE '%关键字3%' OR `title` LIKE '%关键字4%'
ORDER BY ((CASE WHEN `title` LIKE '%关键字1%' then 3 else 0 end)+(CASE WHEN `title` LIKE '%关键字2%' then 1 else 0 end)) DESC LIMIT 0, 4