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