i can't reach that site right now -- maybe they're busy running a join (heh)
here's the way i would write this with subqueries:
Code:
select PageCat.*
, COUNT(PageDocPageCatID) AS DocCount
, X.ImgCount
FROM PageCat
LEFT
JOIN PageDoc ON PageCatID = PageDocPageCatID
LEFT
JOIN (
select PageCat.PageCatID
, COUNT(PageImgPageCatID) AS ImgCount
FROM PageCat
LEFT
JOIN PageImg
ON PageCatID = PageImgPageCatID
) as X
ON PageCatID = X.PageCatID
i would call this a derived table, even though technically it's still a subquery
EDIT (number 5): i give up, i just cannot get this board's STUPID wysiwyg to honour my code spacing -- trust me, it looks a lot better properly indented
Bookmarks