Order Result in Sqlite

Posted by saturngod on Stack Overflow See other posts from Stack Overflow or by saturngod
Published on 2010-05-10T05:39:19Z Indexed on 2010/05/10 5:44 UTC
Read the original article Hit count: 398

Filed under:

In MySQL , my sql is like following

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`

This sql is not working in SQlite. I want to do result order.

SELECT * FROM dblist where word like 'sim' or word like 'sim%' or word like '%sim%' or word like '%sim'

equal sim is a frist , sim% is second and %sim% is a thrid and then %sim is a last.

Currently I can't sort like mysql in sqlite. How to change sql to order the result ?

© Stack Overflow or respective owner

Related posts about sqlite