php while döngüsü kullanarak ve mysql sorun

2 Cevap php

Benim en son forum konularını göstermek ve bazı alanları saymak için bir süre döngü kullanarak im

Ben bir sorguda bunu yapmak için çalışıyorum ve burada benim kodu:

  SELECT t.*,p.*,
       SUM(t.topic_approved='1') AS Amount_Of_Topics,
       SUM(t.topic_views) AS Amount_Of_Topic_Views,
       SUM(t.topic_replies) AS Amount_Of_Topic_Replies, 
       SUM(p.post_approved ='1') AS Amount_Of_Posts
    FROM  bb3topics t left join  bb3posts p ON t.topic_id=p.topic_id
    ORDER BY t.topic_last_post_id DESC LIMIT 10

sorun:

Bu kod bir forum konusu değil kalanı sadece gösterir

benim sorgu koduyla yanlış bir şey var mı?!

2 Cevap

Evet.

TOPLA hep fıkra GROUP BY ile kullanılır

Evet eksik GROUP BY. Vardır