ist nicht die beste Lösung aber zu mindest bekomme ich die richtigen Ergebnisse ^^
SQL-Code:
SELECT c.id, c.itemname, a.alevel,
a.itemname, count(s.id) As Anzahl1, (
SELECT count(p2.id)
FROM tblcats c2
LEFT JOIN tblsubcats s2
ON c2.id = s2.parentcat
LEFT JOIN tblpics p2
ON p2.parentsubcat = s2.id
INNER JOIN tblaccesslevels a2
ON c2.alevel = a2.alevel
WHERE s2.alevel <= 1
AND c2.id = c.id
GROUP BY c2.itemname
) As Anzahl2
FROM tblcats c
LEFT JOIN tblsubcats s
ON c.id = s.parentcat
INNER JOIN tblaccesslevels a
ON c.alevel = a.alevel
WHERE s.alevel <= 1
GROUP BY c.itemname;