dimanche 13 septembre 2015

Ordering results (from a search) by number of matches - using SQLite

i'm implementing search for an Android app using an SQLite db, and am wanting to order the results from a search according to the number of matches in a TEXT column

For example let's say that my db table is called article, the TEXT column i want to search is called article_main_text, and that the the user searches for the word "friend". Then i want the db table rows which have the highest number of occurrences of "friend" in their article_main_text column to be shown first

I already know that i can provide custom SQLite statements in the sort order in my CursorLoader (for example supplying this to the CursorLoader constructor), so i'd like to ask: How can i write SQLite code that orders the results with the help of SQLite?

Grateful for help! Kind Regards, Tord

Aucun commentaire:

Enregistrer un commentaire