查询重复标题语句
select title from t_news_temp group by title having count(*)>1
delete from t_zb_temp
where f_title in
(
select a.f_title FROM (select f_title from t_zb_temp group by f_title,f_no having count(*)>1) a
)
select f_title from t_zb_temp group by f_title,f_no having count(*)>1
这句话的意思是查询出来了表中重复数据的标题
delete from t_zb_temp
where f_title in
(
select a.f_title FROM (select f_title from t_zb_temp group by f_title,f_no having count(*)>1) as a
)
select a.f_title FROM (select f_title from t_zb_temp group by f_title,f_no having count(*)>1) as a
从刚刚查出来重复的标题在 ,查出来标题 ,现在
select a.f_title FROM (select f_title from t_zb_temp group by f_title,f_no having count(*)>1) as a
相当于是一张中间表,之后再从t_zb_temp删除标题在中间表里边的。
运行之后删除成功,
如果没有
select a.f_title FROM (select f_title from t_zb_temp group by f_title,f_no having count(*)>1) a 这句话。
运行下面这行sql
delete from t_zb_temp
where f_title in
(
select f_title from t_zb_temp group by f_title,f_no having count(*)>1
)
会报错,不能在from子句中为update指定目标表t_zb