Tag Archives: 删除重复记录

PHP+MYSQL 两行Query搞定删除重复数据

$db=mysql_connect('localhost','xxx','xxx');
//text为可能存在重复的字段名,先用count子句来把TEXT重复的记录的ID拎出来,不全拎,节省资源~

mysql_select_db('vbnew');
$sql="SELECT id, text, count( text )
FROM `dic`
GROUP BY text
HAVING count( text ) >1";
$result=mysql_query($sql)or die("Inva[......]

继续阅读