Я пытаюсь использовать разные с REGEXP_REPLACE, и возвращается 0 строк.
Я создал тестовую таблицу в MySQLP v8.0
CREATE TABLE phone(
id serial primary key,
phone_number char(25));
INSERT INTO phone (phone_number)
VALUES ('(423) 330-9999');
INSERT INTO phone (phone_number)
VALUES ('(423)3309999');
INSERT INTO phone (phone_number)
VALUES ('423-330-1111)');
INSERT INTO phone (phone_number)
VALUES ('1-423-330-6666');
INSERT INTO phone (phone_number)
VALUES ('1A423*330*1111');
INSERT INTO phone (phone_number)
VALUES ('5553301111');
- Тогда
select
REGEXP_REPLACE(phone_number, '[^0-9]', '',1, 0, 'm') as clean_phone
from phone
--- отлично работает -> clean_phone 4233309999 4233309999 4233301111 14233306666 14233301111 5553301111
--- count
select
count(REGEXP_REPLACE(phone_number, '[^0-9]', '',1, 0, 'm')) as
clean_phone
from phone
--- отлично работает -> clean_phone 6
- отличный clean_phone
select
distinct(REGEXP_REPLACE(phone_number, '[^0-9]', '',1, 0, 'm')) as
clean_phone
from phone
--- возвращает пустое значение -> clean_phone
Я не понимаю, почему отличный не работает?