SELECT p.id ,c.text FROM posts p LEFT JOIN( SELECT c.postid

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

SELECT
p.id
,c.text
FROM posts p
LEFT JOIN(
  SELECT
  c.postid
  ,MAX(c.creationdate) as latest_comment
  FROM comments c
  GROUP BY c.postid) s
ON s.postid = p.id
JOIN comments c
ON p.id = c.postid
where s.latest_comment = c.creationdate

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results