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 looks explicitely for the join in the data
用左外部连接替换内部连接
change to left join
SELECT C.id, C.jcat_name,COUNT(A.catid) AS catid FROM jt_categories C
LEFT JOIN jt_articles A ON C.id = A.catid GROUP BY C.id
将INNER JOIN
更改为LEFT JOIN
。
Did u try LEFT JOIN ? bc. (i think) in second table u have NULL articles for some categories.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.