I have two simple tables. One - list of forums, second - list of
messages and i want to
get the list of forums with number of messages in each.
Here is the query:
SELECT forums.id , COUNT( forum_msg.id ) AS cnt
FROM forums
LEFT JOIN forum_msg ON forums.id = forum_msg.forum_id
ORDER BY
You need to group by forum_id...
On 2/19/09 11:09 AM, Artem Kuchin mat...@itlegion.ru wrote:
I have two simple tables. One - list of forums, second - list of
messages and i want to
get the list of forums with number of messages in each.
Here is the query:
SELECT forums.id , COUNT(
SELECT forums.id , COUNT( forum_msg.id ) AS cnt
FROM forums
LEFT JOIN forum_msg ON forums.id = forum_msg.forum_id
ORDER BY forums.sorder ASC
Missing GROUP BY.
PB
-
Artem Kuchin wrote:
I have two simple tables. One - list of forums, second - list of
messages and i want to
get the list of
Following the documentation available at
http://dev.mysql.com/doc/refman/5.0/en/join.html
t1t2
a b a c
--- ---
1 x 2 z
2 y 3 w
Then a natural left join would product these results
mysql SELECT * FROM t1 NATURAL LEFT JOIN t2;
+--+--+--+
| a| b