# How to use count associated in ORM Cakephp 3.2?

**URL:** https://discourse.cakephp.org/t/how-to-use-count-associated-in-orm-cakephp-3-2/1039
**Category:** Need Help
**Created:** [August 23, 2016, 5:04pm UTC](https://discourse.cakephp.org/t/how-to-use-count-associated-in-orm-cakephp-3-2/1039 "2016-08-23T17:04:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mehdifathi](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mehdifathi/32/241_2.png) [@mehdifathi](https://discourse.cakephp.org/u/mehdifathi)
#### Post date: [August 23, 2016, 5:04pm UTC](https://discourse.cakephp.org/t/how-to-use-count-associated-in-orm-cakephp-3-2/1039/1 "2016-08-23T17:04:15Z")

</div>

Hi guys.I want to use two example Mark story in query.php in find count of comment and find count others.i mean this code  
`$query ->select(['total_comments_markstory' => $query->func()->count('Comments.id')]) ->leftJoinWith('Comments.Users', function ($q) { return $q->where(['username' => 'markstory']); ) ->group(['Users.id']);`

`$query ->select(['total_comments_john' => $query->func()->count('Comments.id')]) ->leftJoinWith('Comments.Users', function ($q) { return $q->where(['username' => 'john']); ) ->group(['Users.id']);`

But this code find just john !. I am looking for run two of my queries.but it sounds just run last query.can you help me about this problem?.Thanks
