Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.49 KB | None | 0 0
  1. SELECT  forum_thread.*,  p1.username AS user, COUNT(test2.id) AS replies, p2.username AS reply, max(test2.id) as lastid
  2. FROM forum_thread
  3. LEFT JOIN people AS p1 ON forum_thread.uid = p1.id
  4.  
  5. LEFT JOIN (Select * from
  6. forum_comment
  7. ORDER BY id DESC) as test2
  8.      ON forum_thread.id = test2.ftid
  9.  
  10. LEFT JOIN people AS p2 ON test2.uid = p2.id
  11. Where forum_thread.fcid = $id
  12.  
  13.  
  14. GROUP BY forum_thread.id
  15. ORDER BY forum_thread.type DESC, test2.post_time DESC, test2.id DESC,  forum_thread.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement