Ok I am really close now...
I got it so that it works sorta the way i want it too using the WHERE statement BUT
It only shows categoryb names if there are links in subcat/subcat
I need it to show the other categoryb names even though there is none listed in subcat/subcat so that it shows a count of ( 0 ) for the others.
$query = "SELECT s.subcat,
COUNT(s.subcat) AS num,
c.*
FROM subcat AS s,
categoryb AS c
WHERE categoryg='$cate' AND s.subcat=c.categoryb
GROUP BY c.catb_id";
$result = mysql_query($query)
or die ("Couldn't execute query: ".mysql_error());