SELECT `t`.*, `p`.`dateCreate`, `p`.`idPost`, `p`.`idUser`, `u`.`login`, `u`.`idUser`, `u`.`isAdmin`, COUNT(p2.idPost) AS `posts`, MAX(p2.dateCreate) AS `dateReply`, `c`.`code` AS `countryCode`, `c`.`name` AS `countryName` FROM `topics` AS `t` INNER JOIN `posts` AS `p` ON t.idPost = p.idPost INNER JOIN `users` AS `u` ON p.idUser = u.idUser LEFT JOIN `posts` AS `p2` ON t.idTopic = p2.idTopic LEFT JOIN `countries` AS `c` ON u.userCountry = c.idCountry WHERE (t.idForum = 2) AND (p.idPost != p2.idPost) GROUP BY `t`.`idTopic` ORDER BY `dateReply` DESC
Nie wyświetlają mi się natomiast tematy nie mające odpowiedzi. Próbowałem kombinować z instrukcją warunkową IF(), ale do niczego nie doszedłem.