题解 | 电话号码格式校验(无正则)
电话号码格式校验
https://www.nowcoder.com/practice/2c2453e909c04c29a04c11e9d6b2c769
SELECT t.id, t.name, t.temp AS phone_number
FROM (SELECT id, name,
REPLACE(phone_number,'-','') AS phone_number,
phone_number AS temp FROM contacts) t
where ((LENGTH(t.phone_number) = 10 AND LOCATE('-', t.temp) = 0)
OR (t.temp LIKE '___-___-____'))
AND SUBSTRING(t.phone_number,1,1) != 0
ORDER BY t.id;