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;

```
Combine `day1` and `day2` column to one, then count.

**Query**

```
select t1.ID, t1.Name, count(t2.[day]) as occur
from table2 t1
left join 
(select Day1 as [day] from table1
union all 
select Day2 as [day] from table1) t2
on t1.ID = t2.[day]
group by t1.ID, t1.Name;

```