X
X
xxx44yyy2019-01-21 18:48:26
SQL
xxx44yyy, 2019-01-21 18:48:26

How to leave only letters in the selection?

There is a table in which one column is headings. I would like to make a series of all the first unique letters.
I do it like this:

select distinct *
from (
       select substr(title, 0, 2) as charters
       from posts) as list
order by charters asc;

As a result, I get what I need, but:
a) I don’t like that a subquery is used, can I somehow do without it?
b) not only letters get into the result, how to get rid of this?
Now the output is:
"
(
1
4
5
E
I
R
S
T
«
А
Б
В
Д
Е
Ж
З
И
К
Л
М
Н
О
П
Р
С
Т
У
Ф
Х
Ц
Ч

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
O. J, 2019-01-21
@xxx44yyy

select distinct substr(title, 1, 1) as charters from posts where title REGEXP '^[a-zA-Zа-яА-Я]' order by charters asc

select from the title only those lines in which the first character will be a letter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question