Chapter 4: Advanced CRUD Operations Lab 1: Logic Operators query

I can’t figure why would this query not working? can someone explain?

Pop is not greater than 1000000 and Pop is not less than 5000, should return all in between correct?

db.zips.find(
{
  "$and": [
    {
      "pop": {
        "$not": {
          "$gt": 1000000
        }
      }
    },
    {
      "pop": {
        "$not": {
          "$lt": 5000
        }
      }
    }
  ]
}
).count()

Hi @Andy_Ho,

Yes correct,

We tried the above MQL query and this is what we got:

In case you are not getting the same please reload the sample data and then fire your MQL query, you will get the expected value.

Thanks,
Kushagra

1 Like

Thanks, i simply just forgot to change the directory of my collections