Take the 2-minute tour ×  The wp_posts table seems to retain all
revisions of the same, ok very similar but presumably different,
posts/pages/whatever.  I'm somewhat conversant with SQL but not
WordPress. I need to extract just those records which would
appear on the public facing site; so just the most recent
revision, and not all the superceded rows. Not sure how to
filter the fields. Obviously something more complicated than:
select * from wp_posts where post_status in
('publish','revision') order by post_modified desc  which has
'duplicates' and seems to miss some stuff.  share|improve this
question Do you need to do this via SQL? Why not WordPress
functions? –  Rarst Sep 14 '11 at 10:11 +1 on @Rarst. Plus: If
you get duplicates, use DISTINCT. –  kaiser Sep 14 '11 at 11:02
add comment  2 Answers  up vote 4 down vote accepted  Rather
than constructing query from scratch, it is easier to see what
exactly is WordPress querying when API function is used:
'numberposts' => -1,  var_dump( $wpdb->l