# Mysql row counting

**URL:** <https://forum.kirupa.com/t/mysql-row-counting/300549>\
**Category:** programming\
**Created:** [November 23, 2009, 3:19pm UTC](https://forum.kirupa.com/t/mysql-row-counting/300549 "2009-11-23T15:19:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drummer392](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@drummer392](https://forum.kirupa.com/u/drummer392)\
**Post date:** [November 23, 2009, 3:19pm UTC](https://forum.kirupa.com/t/mysql-row-counting/300549/1 "2009-11-23T15:19:01Z")

</div>

I have a table called pages. In this table are columns called ‘is\_cat’ and ‘catid’.

‘cat\_id’ is a column that gives each page a category id.  
‘is\_cat’ tells whether the page is a regular page or subpage by giving a ‘0’ or ‘1’.

What I am wanting to do is loop through each page and grab how many subpages there are for each category. Then I want it to produce a certain variable for each time there is a subpage.

So for instance, the category ‘Fire Forensics’ might have 5 pages. 2 of them are subcategories. So I want the code to tell me that I have 2 subcategories for that category and produce a variable 2 times.

I hope I explained this well enough. Can anyone help me?
