View Single Post
  #2  
Old 05-22-2007, 06:09 AM
gilbert gilbert is offline
Senior Member
 
Join Date: Dec 2005
Posts: 110
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 20
gilbert is on a distinguished road
Default Re: multi-functions on multi-tables??

Yes, SQL aggregates multiply across multiple joins. So, try to use temp tables or subqueries, such as:

SELECT
f.*,
(SELECT COUNT(t.topic_id) FROM mt_forum_topics t WHERE t.forum_id=f.forum_id),
(SELECT COUNT(f.post_id) FROM mt_forum_posts f WHERE p.forum_id=f.forum_id),
FROM mt_forums f; -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - multi-functions on multi-tables??
View Single Post
  #2  
Old 05-22-2007, 06:09 AM
gilbert gilbert is offline
Senior Member
 
Join Date: Dec 2005
Posts: 110
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 20
gilbert is on a distinguished road
Default Re: multi-functions on multi-tables??

Yes, SQL aggregates multiply across multiple joins. So, try to use temp tables or subqueries, such as:

SELECT
f.*,
(SELECT COUNT(t.topic_id) FROM mt_forum_topics t WHERE t.forum_id=f.forum_id),
(SELECT COUNT(f.post_id) FROM mt_forum_posts f WHERE p.forum_id=f.forum_id),
FROM mt_forums f; -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote