Question: I have checked all the posts on the subject, and added a callback in the iterator. 
However, it seems it does not work. 

```js
  async.forEachOf(scoreTree.nodes, function (node,key, callback){
          if(!node.composition.weights){
            mongooseCall.etc.find({}
            }
            ,function (err, data) {
              //some synchronous code
              //use data to update node... 
              callback(null);
            });
          }
       },function (err) {
         lastCall(err, scoreTree, function () {scoreTree.save();});
       });
```

Thank you for your help!
Marouane.

Answer: 
It seems you want to count how many rows in `table1` have a matching value in either column. One easy way is:

```
select t2.*,
       (select count(*)
        from table1 t1
        where t2.id in (t1.day1, t1.day2)
       ) as occur
from table2 t2;

```
In table 1, you must make a foreign key for the table 2. Probably the id of user. With that:

```
Select t2.id, t2.name, Sum(t1.day) 
from table1 t1
innerjoin table2 t2 
on t1.id = t2.id

```