Unable to use and & or together

db.movies.find({$and:[{$or:[{“cast”:“Jack Nicholson”},{“cast”:“John Huston”}],{‘viewerRating’:{$gt:7}},{‘mpaaRating’:“R”}}]})

I used the above query.but it didn’t run

Not sure what this means?

Sorry, if i wasn’t clear.For question 6, I used the above the query. But it gave the error:" syntaxError: Expected property name got ‘{’
But i can’t what seems wrong in the query.

I was hinting that you need to include the error message :wink:

Is that exactly how you wrote it? Don’t you use indentation and correct spacing?

Here’s a good example for you @Rahul_14779:
https://docs.mongodb.com/manual/reference/operator/query/and/#and-queries-with-multiple-expressions-specifying-the-same-operator

Follow this style of writing and you’ll fix the syntax error.

there wasn’t any space or indentation.

See the example in the link

Thank you. Found my mistake.

Very good! :slight_smile::+1:

Hi @Rahul_14779,

I’m glad your issue got resolved. Please feel free to get back to us if you have any other query.

Thanks,
Shubham Ranjan
Curriculum Support Engineer