-1

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?

AlignPx
  • 1
  • 3

1 Answers1

0

Try the following:-

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

or

$db->empoyees->find(array('age1' => array('$lt' => 'age2')));
nandal
  • 2,544
  • 1
  • 18
  • 23
  • $db->empoyees->find(array('age1' => array('$lt' => 'age2'))); this is not working – AlignPx May 25 '18 at 04:56
  • How can I actually write that query using PHP mongodb driver : $db->empoyees->find( array('$where' => 'this.age1 < this.age2' ) ); – AlignPx May 25 '18 at 04:56