【发布时间】:2013-03-28 00:32:28
【问题描述】:
我正在使用以下查询从表中选择重复的电话号码。
SELECT id, REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( phone, "+", '' ) , ")", '' ) , "(", '' ) , "-", '' ) , ' ', '' ) AS strippedPhone
FROM `customers`
GROUP BY strippedPhone
HAVING count( strippedPhone ) >1
LIMIT 0 , 300
它看起来很难看,并且不考虑在具有电话号码的字段上出现字母数字字符的可能性。
还有更好的方法吗?
【问题讨论】:
-
您想对重复项做什么 - 从数据库中删除它们?
-
@Revent,我想用它创建一个报告。
-
@pst,不,没有。
-
sql clr 函数,因此您可以使用 .net 来规范手机将为您提供更多工具