如何选择重复的自由职业者。com帖子?
post_id meta_key meta_value
-------- ------------------- ----------------------------------------
1 syndication_permalink https://www.freelancer.com/projects/
2 syndication_permalink https://www.freelancer.com/projects/
3 syndication_permalink https://www.freelancer.com/projects/
4 syndication_permalink https://www.simplyhired.com/job/W6sVJ1
5 syndication_permalink https://www.mandy.com/uk/job/576913/junior
我真的想把他们的状态改为草稿
*UPDATEI最终修改了一些代码,并以某种方式实现了这一点。我不得不破解其他代码,我的SQL sux。但这是可行的。我现在只想知道如何做的不仅仅是“选择”,还要将帖子状态更新为“草稿”。现在似乎不知道如何对SELECT查询进行更新
from wp_posts as bad_rows
LEFT JOIN wp_postmeta c ON ( bad_rows.ID = c.post_id )
inner join (
select post_title,id, MIN(id) as save_this_post_id
from wp_posts
inner JOIN wp_postmeta c ON ( wp_posts.ID = c.post_id )
WHERE (
`post_status` = \'publish\'
AND meta_key = \'syndication_permalink\'
)
group by meta_value
having count(*) > 1
) as good_rows on good_rows.post_title = bad_rows.post_title
and good_rows.save_this_post_id <> bad_rows.id
and (bad_rows.post_status=\'publish\' AND meta_key = \'syndication_permalink\' )
order by post_title,id;