in reply to Counting rows from table1 while querying table2

I don't think this is a perl question, and anyway, you haven't quite given the right info to get the right answer. But I'll try guessing at an answer anyway...

If the table "posts" has a field called "catid" such that many rows may have the same value in this field, and if the table "categories" also has a field called "catid" such that each catid value occurs in exactly one row, then you might be looking an sql statement like this:

select id, catname, catdesc, count(p.catid) from categories c, posts p where p.catid = c.catid group by p.catid
But I'm just guessing, based on the fact that you say you want to "determine how many 'posts' were found..." If that doesn't work for you, you should consult a good resource for teaching SQL. Posting sql syntax questions to PerlMonks is okay if you do it in the Chatterbox. As a SoPW node, it's "off-topic".