如题,数据库记录共有100万条,我目前查找的sql 是select count(content) as sum,tables.* from tables where content GROUP BY content HAVING count(content)>1
效率不高并且有些重复信息没有搜索出来,请教大家有没有更好的办法? 谢谢!
效率不高并且有些重复信息没有搜索出来,请教大家有没有更好的办法? 谢谢!
select a.* from tables a inner join
(select content from tables GROUP BY content HAVING count(content)>1) b
on a.`content`=b.`content`
在content字段上建立索引
sid id datetime content status catgory
302273 10267 2009-03-03 10:37:06 鸡营养还不错地。。所以还蛮喜欢吃的 杭州宋城大饭店地处上城区。 1 餐饮
宋城大饭店是宋都集团所属企业,于97年底开始营业,距杭州火车城站
800米,...
要求的结果就是与 “营养还不错地。。所以还蛮喜欢吃的 杭州宋城大饭店地处上城区。宋城大饭店是宋都集团所属企业,于97年底开始营业,距杭州火车城站800米,... ”相同的都找出来并且标注status=0
sid id datetime content status catgory
302273 10267 2009-03-03 10:37:06 鸡营养还不错地。。所以还蛮喜欢吃的 杭州宋城大饭店地处上城区。 1 餐饮
宋城大饭店是宋都集团所属企业,于97年底开始营业,距杭州火车城站
800米,...
要求的结果就是与 “营养还不错地。。所以还蛮喜欢吃的 杭州宋城大饭店地处上城区。宋城大饭店是宋都集团所属企业,于97年底开始营业,距杭州火车城站800米,... ”相同的都找出来并且标注status=0
应该是最快的方法相同的都找出来并且标注status=0
update tt a inner join
(select content from tables GROUP BY content HAVING count(content)>1)
b
on a.`content`=b.`content`
set a.status=0
on a.`content` = b.`content`
set a.status=0
update yourTable a
set status=0
where exists(select id from yourTable where `content` =a.`content` and id!=a.id);
(select content,max(id) as ma from tables GROUP BY content HAVING count(content)>1)
b
on a.`content`=b.`content` and a.id=b.ma
set a.status=0也可以和MAX->MIN,假设你以ID为唯一标识的字段
update yourTable a
set status=0
where exists(select id from yourTable where `content` =a.`content` and id<a.id);