E
E
eldar_web2017-08-19 21:35:42
MySQL
eldar_web, 2017-08-19 21:35:42

How to sort alphabetically in a model in Ruby on Rails (MySQL) excluding extra words?

For example, there is an Address model with name fields.
And so the following records:
- Moscow, Borodin street
- Republic of Bashkiria, Ufa, Pushkin
street - Hitler street
That is, I want to sort alphabetically only STREETS, but as you can see, before the name of the street there may be different information, in fact, the last the word in the entry is this street.
How can I sort alphabetically meaning only streets?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2017-08-20
@2ord

To compose an SQL query, you must first have a separate street name field in the table that the MySQL engine needs for sorting.
This problem cannot be solved without splitting the address into its component parts, in which the street name will be stored separately.
For addresses in Russia, you can one-time use third-party databases of addresses to separate addresses, such as KLADR.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question