On 2015-08-19 02:40 PM, Simon Slavin wrote:
>
> SELECT rowid FROM NameTable
> WHERE name BETWEEN 'P' AND 'PZZZZ'
> ORDER BY name
> LIMIT 1
>
> This will execute faster if you have an index on 'name' in NameTable.
>
> [Yes I know 'PZZZZ' is lazy. Until you find someone with that name
> (presumably Polish) with that name bite me.]
Reminds me of my great-aunt, Pzzzzenna Borowitz. I do miss her!
Seriously though, if that column is not COLLATE NOCASE declared, 'PZZZ'
will fail. Either ensure your column has COLLATE NOCASE or perhaps
simply choosing the highest (non UTF-8) character such as:
WHERE name BETWEEN 'P' AND 'P~'
will suffice.
Cheers!
Ryan