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
评论前必须登录!
立即登录 注册