Manipulate string
Hi all.
This is my initial email string in MySQL:
chevymark.sunderland@9651.com
I try this query:
Now I need this other output:Code:mysql> SELECT REPLACE ( SUBSTRING_INDEX( 'chevymark.sunderland@9651.com', '@', 1 ), '.', ' ' ) AS output; +----------------------+ | output | +----------------------+ | chevymark sunderland | +----------------------+ 1 row in set
would be to say the first three consonants of the name and first three consonants of the surname.Code:+---------+ | output | +---------+ | chv snd | +---------+
alternatively three random characters from the name and surname...
I try this query but the output is wrong:
how can i do it?Code:mysql> SELECT CONCAT( LEFT ( REPLACE ( SUBSTRING_INDEX( 'chevymark.sunderland@9651.com', '@', 1 ), '.', ' ' ), 3 ), ' ', ( LEFT ( REPLACE ( SUBSTRING_INDEX( SUBSTRING_INDEX( 'chevymark.sunderland@9651.com', '@', 1 ), '.', ' ' ), ' ', - 1 ), 3 ) ) ) AS output; +--------+ | output | +--------+ | che | +--------+ 1 row in set
any help?
thank you.



Reply With Quote



Bookmarks