发布于 4年前

MySQL 模糊查询按匹配度排序

// 查询 title 包含 "中国" 或 "好声音" 的内容,并按匹配度排序

select * from xxx
where
title like '%中国%'
or
title like '%好声音%'
order by
case when title like '%中国%' then 1 else 0 end +
case when title like '%好声音%' then 1 else 0 end
©2020 edoou.com   京ICP备16001874号-3