1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| SELECT
c.salon_lib AS cat_titre,
c.description AS cat_stitre,
sc.salon_lib AS for_titre,
sc.description AS for_desc,
sc.salon_id AS for_id,
COUNT(post.post_id) AS nb_posts,
COUNT(DISTINCT topic.topic_id) AS nb_topics,
COUNT(DISTINCT topics_lus.topicl_id) AS nb_lu,
topic2.topic_title AS dern_titre,
topic2.topic_id AS dern_t_id,
topic2.topic_timestamp AS dern_date,
users.pseudo AS dern_pseudo,
users.user_id AS dern_u_id
FROM salon as sc
LEFT JOIN salon AS c ON c.salon_id = sc.parent_id
LEFT JOIN topic ON topic.topic_salon = sc.salon_id
LEFT JOIN post ON post.post_topic = topic.topic_id
LEFT JOIN topics_lus ON topics_lus.topicl_id = topic.topic_id AND topics_lus.userl_id=161
LEFT JOIN users ON users.user_id = topic.topic_user
LEFT JOIN (
SELECT topic_id, topic_title, topic_timestamp, topic_salon
FROM topic
ORDER BY topic_timestamp DESC
) topic2
ON topic2.topic_salon = sc.salon_id
GROUP BY sc.salon_id
ORDER BY sc.parent_id |
Partager