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
  • 622
  • 8
  • 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
  • 502,043
  • 27
  • 286
  • 360