select * from contacts
where
# 含"-"和不含"-"的情况分开检验
(
phone_number RLIKE '^[0-9]+$'
and
phone_number not like "0%"
and
length(phone_number) = 10
)
or
(
replace(phone_number, "-", "") RLIKE '^[0-9]+$'
and
phone_number not like "0%"
and
phone_number like "___-___-____"
)
order by id asc;

京公网安备 11010502036488号