select Name, count(ItemID) as itemCount from table1 inner join table2 on table1.ItemID = table2.id group by Name
but my sql-fu might be rusty: P
Note that this will not give strings for names where table2 does not contain matching strings, so itemCould will always be> 0
source share