简体   繁体   中英

Return filtered LIKE results in SQLite using FMDB

Using SQLite is there a way of using the LIKE command where the search parameter could find results that would be considered a substring of itself

ie. a search parameter of "delicious and tasty fruit and cinnamon." could return "delicious and tasty" in a DESC order by length so that if delicious was also a returned result it would show up last.

searching for "delicious and tasty fruit and cinnamon." could return...

 delicious and tasty fruit
 delicious and tasty
 delicious

You don't need LIKE for that:

SELECT * FROM [foo]
WHERE a = substr('delicious and tasty fruit and cinnamona', 1, length(a))
ORDER BY length(a) DESC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM