Created
March 8, 2011 08:51
-
-
Save fasthold/860049 to your computer and use it in GitHub Desktop.
简易模糊查询 按相关性排序 SQL语句
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * , IF( `Word` = 'sim', 1, IF( `Word` LIKE 'sim%', 2, IF( `Word` LIKE '%sim', 4, 3 ) ) ) AS `sort` FROM `dblist` WHERE `Word` LIKE '%sim%' ORDER BY `sort` , `Word` | |
# 得到结果: | |
1. sim | |
2. sim* | |
3. *sim* | |
4. sim* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from http://stackoverflow.com/questions/5215982/sort-value-in-mongodb