日期:2014-05-18  浏览次数:20526 次

关于排序的。
有什么办法可以搜索   某一表中的一列,   按匹配的程度排序呢?
例如,查标题是“美女”的,将标题是“美女”的放在前面,接着就放 "%美女% "的,也按匹配的程度排列?  

例如标题表中有
table1
          title
          她是美女
          美女
          臭美的女人
          美女快来啊

以上如果搜   “美女”
就按
          美女
          她是美女
          美女快来啊
排序列出来。
帮帮忙,谢谢。。。

------解决方案--------------------
select * from table1 where title like '%美女% ' order by len(title)

------解决方案--------------------
select * from table1 where charindex( '美女 ',title) > 0 order by charindex( '美女 ',title) asc