[英]Count number of articles in categories
This code only shows categories with articles in them. 此代码仅显示其中包含文章的类别。 I want to show all categories.
我想显示所有类别。 Pls help.
请帮助。
$query = "SELECT C.id, C.jcat_name,COUNT(A.catid) AS catid FROM jt_categories C INNER JOIN jt_articles A ON C.id = A.catid GROUP BY C.id";
Change INNER JOIN for LEFT JOIN in your query. 在查询中将INNER JOIN更改为LEFT JOIN。
INNER JOIN looks explicitely for the join in the data INNER JOIN明确寻找数据中的联接
用左外部连接替换内部连接
将INNER JOIN
更改为LEFT JOIN
。
Did u try LEFT JOIN ? 您尝试过LEFT JOIN吗? bc.
公元前。 (i think) in second table u have NULL articles for some categories.
(我认为)在第二张表中,某些类别的文章为NULL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.