SQL – JOIN last child
This is the solution I came up with: SELECT child_ID, posts.post_author, wp1.post_author FROM wp_posts posts LEFT JOIN ( SELECT MAX(ID) as child_ID, post_parent FROM wp_posts WHERE post_type=”ticket_reply” GROUP BY post_parent ) sl ON posts.ID = sl.post_parent INNER JOIN wp_posts wp1 on sl.child_ID = wp1.ID WHERE posts.ID = 1499