sql-befehl für new posts
    
		
    
       tomstig  20.12.2004 - 22:29  673  4 
    
		
		
  	
    
    	
      
    
    
    
			
  | tomstig
      OC Addicted   | 
         also, da ich grad das phpbb nach meinen wünschen formatier brauch ich folgendes: genau das, was ihr auch auf der linken seite habt - das new posts... so weit hab ich schon das: SELECT t.topic_title, u.username, p.post_time
FROM  `posts` p 
LEFT  JOIN topics t
USING ( topic_id ) LEFT JOIN users u ON u.user_id = p.poster_id 
ORDER  BY p.post_time DESC 
LIMIT 0 , 7
 das einzige was mir noch fehlt, ist, dass immer nur ein topic_title geladen wird, also wenn die letzten 7 antworten in einem topic waren, sollen nicht nur diese angezeigt werden, sondern eben 7 verschiedene topics... geht das überhaupt nur in mysql oder in php (stell ich mir grad noch unmöglicher vor)
     | 
  | murcielago
      Dr. Doom   | 
         "select DISTINCT"  und dann deins
     | 
  | tomstig
      OC Addicted   | 
         SELECT DISTINCT t.topic_title, u.username, p.post_time
FROM `posts` p
LEFT JOIN topics t
USING ( topic_id )
LEFT JOIN users u ON u.user_id = p.poster_id
ORDER BY p.post_time DESC
LIMIT 0 , 7
 das ist das ergebnis...zak... und neu??  	wappler  	1103577806 zak... und neu?? 	tomstig 	1101470491
 jj 	tomstig 	1101421349
 jj 	tomstig 	1101421332
 jj 	tomstig 	1101421317
 jj 	tomstig 	1101421302
 jj 	tomstig 	1101421287
 sprich "zak... und neu" würde 2x angezeigt werden - genauso wie jj...
     | 
  | h4de5
      -   | Bearbeitet von h4de5 am 20.12.2004, 23:58
         a group by t.topic_title gehört vors order by und beim select max(p.post_time) bei u.username und gehört noch a 2. aggregatfunktion. aba da fällt ma jez nix ein. edit also so ähnlich: SELECT DISTINCT t.topic_title, u.username, max(p.post_time)
FROM `posts` p
LEFT JOIN topics t
USING ( topic_id )
LEFT JOIN users u ON u.user_id = p.poster_id
group by t.topic_title, u.username
ORDER BY p.post_time DESC
LIMIT 0 , 7 
 aber das passt noch ned ganz. weil dann wahrscheinlich "zak... und neu??" wieder zweimal kommt (unterschiedlicher poster) edit2: hiaz hammas    SELECT DISTINCT t.topic_id, t.topic_title, max(p.post_id), u.username, max(p.post_time)
FROM `posts` p
INNER JOIN topics t ON t.topic_last_post_id = p.post_id
INNER JOIN users u ON u.user_id = p.poster_id
GROUP BY t.topic_id, t.topic_title, u.username
ORDER BY p.post_time DESC
LIMIT 0 , 7 
 obwohl, wenn ich mir des recht überlege, wär a subselect noch immer gscheita. aba dafür bin i hiaz zmüde    | 
  | watchout
      Legendundead
         | 
         bei oc funkt das aber anders - und zwar über den thread-table, alles andere tät zu viel peromance schlucken    |