How to select all names from the table, the first letter of which matches the range of letters from P to Z ?
I made the following request:
SELECT `name` FROM `table1` WHERE `name` BETWEEN 'Р' AND 'Я' ORDER BY `name`
In the resulting selection, there are no results in which
name begins with the letter I , from which I concluded that
BETWEEN selects values, including the first border (P), but not including the second border (I) in the result.
Is it possible to compose such a query so that names with the letter I also appear in the results?
Found this solution:
BETWEEN 'Р' AND 'Я' ORsurname
LIKE 'Я%' ORDER BYname`
But if suddenly someone proposes a more elegant solution, I will be happy to change my approach)
probably not the entire field needs to be compared with a letter, but only the first character:
MySQL 5.6 Schema Setup :
create table t (n text); insert into t values ('яблоки на снегу');
select * from t where n between 'р' and 'я'
select * from t where substring(n,1,1) between 'р' and 'я'
| n | |-----------------| | яблоки на снегу |