Reply to topic
Two COUNTs in a query multipling by each other.
Mauron


Joined: 16 Nov 2004
Posts: 3
Reply with quote
Code:
$result = mysql_query("SELECT     u.userid, u.username, u.level, u.karma, (u.mny + b.bank_mny) AS total_mny, u.mny, u.regsec, b.bank_mny, COUNT(t.username) AS topiccount, COUNT(m.username) AS posts
                         FROM       mny_bank AS b
                         RIGHT JOIN users AS u ON u.username = b.bank_username
                         LEFT JOIN  messages AS m ON u.username = m.username
                         LEFT JOIN  topics AS t ON u.username = t.username
                         GROUP BY   u.username
                         ORDER BY   $order_by $order
                         LIMIT      0, 50") or die(mysql_error());

Whenever the query is run, topiccount and posts are always equal to topiccount times the posts. Could anyone here explain why and tell me how to avoid it?
Two COUNTs in a query multipling by each other.
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic