如何比较PHP mongodb驱动程序中mongodb中同一个表的2列? [重复]

This question already has an answer here:

Please provide me the precise answer to my question by checking the following example :

For example, Table: employees have fields (age1,age2)

I want to do SELECT query

Select count(*) From Employees Where age1 < age2

How can I do that in mongodb php driver functionality?

</div>

Try the following:-

$db->empoyees->find( array('$where' => 'this.age1 < this.age2'  ) );

or

$db->empoyees->find(array('age1' => array('$lt' => 'age2')));