MySQL Forums
Forum List  »  Newbie

First and Last word in string
Posted by: Eder Pardeiro Eder Pardeiro
Date: September 25, 2017 09:26AM

Hi,

I do not know MySQL very well, I know a little more about SQLServer and I'm having a hard time resolving an issue.

I have a table with a column of names where I need the query to return only the first and last name.

For example: José Joaquim da Silva Xavier
Output: José Xavier

In SQLServer I would do so:

_________________________

select
substring(FullName,1,CHARINDEX(' ',FullName)) + Reverse(substring(REVERSE(FullName),1,CHARINDEX(' ',REVERSE(FullName))))
from People

_________________________

How I make this in MySQL?

PS: I'm Brazilian and I do not speak English, I hope you understood.

Options: ReplyQuote


Subject
Written By
Posted
First and Last word in string
September 25, 2017 09:26AM
September 25, 2017 09:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.