samedi 23 janvier 2016

Searching within a search string instead of just the first letters and words with sqlite and Xcode

@"SELECT name,latitude,longitude,amenity,tourism FROM dubai WHERE name LIKE \"%@\" OR amenity LIKE \"%@\" OR tourism LIKE \"%@\" ORDER BY lvl ASC LIMIT 15",
                      keywords, keywords, keywords];

This is sqlite-based search query-handling code that selects the right columns from the right table and processes the information from search queries in an iOS app.

Problem is that with \"%@\" the database only looks for the first word of the search string. I want to show everything that contains the search string. I suspect that there must be a way to adjust \"%@\" to an expression that can facilitate containment searches.

I find this issue hard to formulate: hope the code clarifies what I want to do -which is: replace \"%@\" with X where search queries return results that contain a search string instead of just results that start with the search string //that was better ;)

X = ?

Aucun commentaire:

Enregistrer un commentaire