Reputation: 291
I have this row in my table
I want to get the name Mary Jane only but for some reason its Mary Jane-Jeyxa that I'm getting.
Descriptn is my column name
Could you help me with this? :c
Here's my query:
SELECT substring_index(substring_index(descriptn, ' ', -2), '-', -2) FROM `deposit`
Upvotes: 0
Views: 34
Reputation: 152304
substring_index(descriptn, '-', -2)
query returns last 2 parts splitted by -
character, so: Mary Jane
and Jeyxa
What you can do is split this again by -
and pick the first part:
substring_index(substring_index(descriptn, '-', -2), '-', 1)
Upvotes: 2