select wp_posts. * from wp_posts left join wp_postmeta on ( wp_posts.id = wp_postmeta.post_id ) where 1=1 and wp_posts.post_date < now() group by wp_posts.id order by wp_posts.post_date desc limit 0, 30;
code from this topic:
SELECT g.group_id, COUNT(m.member_id) AS members FROM groups AS g LEFT JOIN group_members AS m USING(group_id) GROUP BY g.group_id HAVING members > 4