I'm new with SQL. I'm trying to get data from database (Postgres) and replace them on the fly if those are not valid. Is this possible to do this using pure SQL? For example in my DB users
I've got the field phone
with following data:
|phone |
------------------
|+79844533324 |
|893233314215 |
|dfgdhf |
|45 |
|+ |
| |
|(345)53326784457|
|8(123)346-34-45 |
etc..
I'd like to get only last ten digits if:
- the phone number starts from 8 or 7 or +7 or +8 .
- the number contains ten digits after 8 or 7 or +7 or +8 not more and not less
like this:
|phone |
------------------
|9844533324 |
|1233463445 |
I guess it might be to complicated for SQL. I've researched ton of manuals but most of them cover just SELECT with regex condition.