Reply To: Sorting by last name goes wrong when having multiple words as last name
@shanebp the only problem with substring_index( substring_index( 'Robin van Persie', ' ', 2), ' ', -1 ) is you lose anything after the 2nd delimiter. For example:
substring_index( 'Robin van Persie', ' ', 2)
would return Robin van
and then
substring_index( 'Robin van', ' ', -1)
would return van
So in theory, the order returned could be
Denis Bergkamp
Stefan de Vrij
Barry van Galen
Robin van Persie
Ruud van Nistelrooy
Wesley Sneijder
As you can see Robin van Persie and Ruud van Nistelrooy are in the wrong order.
Note though – this will only be a problem if you have many people with words like van or de in their name.