1 2 3 4 5 6 7 8 9 10 11 12 13
|
SELECT c.`id` as `cid`, c.`name`, c.`desc`, c.`nbr_topic`, c.`nbr_msg`, c.`type`, c.`statut`, c.`secure`, t.`id` as `tid`,
t.`idcat`, t.`titre`, t.`last_timestamp`, t.`last_user_id`, t.`last_msg_id`, m.`user_id`, m.`login`
FROM `forum_cats` AS c
LEFT JOIN `forum_topics` AS t
ON t.`idcat` = c.`id`
LEFT JOIN `membre` AS m ON m.`user_id` = t.`last_user_id`
LEFT JOIN `forum_topics` AS t2 ON (t.`idcat`=t2.`idcat`)
WHERE c.`aprob`="0"
GROUP BY c.`id` as `cid`, c.`name`, c.`desc`, c.`nbr_topic`, c.`nbr_msg`, c.`type`, c.`statut`, c.`secure`, t.`id` as `tid`,
t.`idcat`, t.`titre`, t.`last_timestamp`, t.`last_user_id`, t.`last_msg_id`, m.`user_id`, m.`login`
HAVING t.`last_timestamp` = MAX(t2.`last_timestamp`)
ORDER BY c.`idcat` ASC |
Partager