This should be doable in one query?
SELECT post_id
WHERE revision_id IN
AND post_id <> 0
LIMIT 1