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
声明:本文为原创文章,版权归主机之家测评所有,欢迎分享本文,转载请保留出处!