Reputation: 149
I have a column which contains client's name and surname in CUSTOMER
table.
11 | John Doe
12 | Kate Sanchez
13 | Amy Lee
The purpose is to select only id-s and names to be displayed in the column, like:
11 | Doe
12 | Sanchez
13 | Lee
The length of names varies, so I can't use SUBSTRING.
Upvotes: 0
Views: 409
Reputation: 222432
Do you want substring_index()
?
select id, substring_index(name, ' ', -1) last_name
from customer
This selects the part of the string that follows the last space.
Upvotes: 3