I would like to know how to select from one table and count from another (loop) using a single query

Table ctagories 

```
------------------------------
cat_id | cat_name | parent_id 
------------------------------
1      | General   | 0
------------------------------
2      | News      | 0
------------------------------
3      | Sports    | 1
------------------------------
4     | Test       | 0
------------------------------

```

Table posts

```
--------------------------------------
post_id| title     | c_id   | active
--------------------------------------
1      | test      | 1      |  1
--------------------------------------
1      | test 1    | 2      |  0
--------------------------------------
1      | test 2    | 1      |  1
--------------------------------------
1      | Test 3    | 3      |  1
--------------------------------------

```

I want display categories `where parent_id=0` (main categories) with the post count (posts `where active = 1`) in front of it 

Ex: General (2 posts)

Can anyone give me a example how to do it with a one query