MySQL Forums
Forum List  »  Newbie

Re: assistance with a DELETE query using an IN subquery
Posted by: Peter Brawley
Date: January 09, 2020 09:56AM

With a batch deletion query like that, it's often safer to run the SELECT version of the query and study the results before running the DELETE.

SELECT a.*
FROM wp_posts a
JOIN (
  SELECT post_title, MAX(post_date) AS latest
  FROM wp_posts 
  WHERE post_type = "revision" 
  GROUP BY post_title
) b OB a.post_title=b.post_title and a.post_date<b.latest;

Options: ReplyQuote


Subject
Written By
Posted
Re: assistance with a DELETE query using an IN subquery
January 09, 2020 09:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.