Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question