2

I would like to print only contact number leaving country code aside using regular expressions. Let us assume a table with 2 contacts

PHONENO
-----------
+89-8646538468
+0222-4684653453465

EXPECTING OUTPUT:

PHONENO
----------------
8646538468
4684653453465
Bharath_Raja
  • 602
  • 5
  • 16

1 Answers1

2

This is very easy using MySQL's SUBSTRING_INDEX function:

SELECT
    PHONENO AS full_number,
    SUBSTRING_INDEX(PHONENO, '-', -1) AS short_number
FROM yourTable;

Demo

Tim Biegeleisen
  • 451,927
  • 24
  • 239
  • 318