MQL returning different results?

will the below MQL will return the same results? If yes, then why? Score is a field inside Grades array.


{grades : { $elemMatch:{“score”:{$gt : 80 , $lt :100}}}}

No they won’t.

With $elemMatch you ensure that both conditions are true within the same element.

While the first one will also match documents that have one element of grades with scores:{$gt:80} and another with score:{$lt:100}.

1 Like

thank you @steevej , I was getting different counts, thanks for the detailed explanation.