Ich habe ein Problem mit dem hierdrunter stehendem SQL SELECT-Statement. Ich bekomme eigentlich alles ausgegeben was ich haben will, nur sind alle posting_* Sachen falsch, denn es wird das erste Vorkommnis in der Datenbank genutzt und nicht das letze. Ich speichere in der DB in snap_forums die ID des letzen Postings in diesem Forum und diese soll auch ausgelesen werden aus snap_postings aber ich bekomme wie schon erwähnt immer nur den ersten Eintrag des Forums und nicht den dem die ID gehört.
	
							
						
					Code:
	
	SELECT
	a.title              AS forums_title,
  	a.ID                 AS forums_id,
        COUNT(DISTINCT b.ID) AS threads_count,
        COUNT(c.ID)          AS postings_count,
        d.username           AS user_name,
        c.ID                 AS posting_id,
        c.title              AS posting_title,
        c.postdate           AS posting_date,
        a.lastpostid         AS lastpost_id
FROM
        snap_forums    a                            LEFT JOIN
        snap_threads   b     ON a.ID = b.FID        LEFT JOIN
        snap_postings  c     ON b.ID = c.TID        LEFT JOIN
        snap_user      d     ON d.ID = c.UID        LEFT JOIN
        snap_forums    e     ON a.lastpostid = c.ID
GROUP BY
        a.ID;
 
          

 
							
						 [/color]
[/color] 
							
						 ) aber wie schon erwähnt bekommsch ned die Anzahl der Postings im Forum. Also sobald ich die ThreadID des Postings änder hab ich im Forum ein Posting weniger obwohl das Posting noch im selben Forum ist nur eben in einem anderen Thread.
) aber wie schon erwähnt bekommsch ned die Anzahl der Postings im Forum. Also sobald ich die ThreadID des Postings änder hab ich im Forum ein Posting weniger obwohl das Posting noch im selben Forum ist nur eben in einem anderen Thread.
							
						
Kommentar