SELECT categories.*, COUNT(categoryID) AS kritCount
FROM categories AS categories
LEFT JOIN krits ON categories.id = categoryID
WHERE (krits.approved = '1')
GROUP BY categories.id
So this works fine except that it does not return a category that has 0 crit counts in the category.
It will be if I delete the WHERE statement, but I need WHERE to select only crits, where field = 1 is approved
source
share