Thanks - using GLOB works well for me. I've done some tests and using GLOB seems faster than using the ">= AND <" approach.
When not matching on a prefix (i.e. '*something*') GLOB and LIKE seems to have similar speeds which I suppose would be expected. On Oct 8, 3:10 pm, skink <[email protected]> wrote: > On Oct 8, 5:36 am, westmeadboy <[email protected]> wrote: > > > > > > > I have a TEXT column and I want to match all rows where the value has > > a certain prefix. For example, > > > WHERE mycol LIKE 'myprefix%' > > > However, I noticed in some optimization guidelines that this will not > > use the index and instead you should do this: > > > WHERE mycol >= 'myprefix' AND mycol < 'myprefiy' > > > Instead of simple A-Z chars, I have a whole variety of UTF-8 chars > > (think chinese characters). > > > My question is, how to work out the next char in UTF-8? > > > Is it enough to add one to the codepoint, such as: > > > String lowerBound = "myprefix"; > > int codepoint = Character.codePointAt(lowerBound, lowerBound.length() > > - 1); > > String upperBound = lowerBound.substring(0, lowerBound.length() - 1) + > > Character.toChars(codePoint + 1); > > String sql = "SELECT * FROM mytable WHERE mycol >= '" + lowerBound + > > '" AND mycol < '" + upperBoundPrefix + "'" > > > ? > > see: > > http://groups.google.com/group/android-developers/browse_thread/threa... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

