select * from #A order by (case charindex('西瓜',text_field) when 0 then 0 else 1 end)
+(case charindex('土豆',text_field) when 0 then 0 else 1 end)
+(case charindex('青椒',text_field) when 0 then 0 else 1 end) desc
解决模糊查询的结果记录排序问题
最新推荐文章于 2022-11-27 17:11:07 发布
本文介绍了一种使用SQL语句进行数据查询的方法,通过使用CASE WHEN结构结合ORDER BY实现对特定字段包含关键词的记录进行排序。这种方法可以有效地对数据库中的记录按是否包含指定关键词进行筛选并排序。
4110

被折叠的 条评论
为什么被折叠?



