0

I have the following query:

db.pmusers.find({'firstName':'Arnold', 'lastName':/^z*/ })

I want to find documents where firstname equals Arnold and lastName starts from Z

But this query returns:

{"firstName" :"Arnold", "lastName" : "tpxjzqi"}

Please correct my query

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • @Neil Lunn, I had read it. And I use sintax like in response – gstackoverflow Aug 08 '17 at 10:02
  • But the problem here is that `*` means **zero or n times**. Zero match means "match anything". So there will be another duplicate, but the question has indeed been asked before. Takes me a moment to find it. Simply `/^z/` works as expected and it's the `*` that is the problem. – Neil Lunn Aug 08 '17 at 10:04
  • @Neil Lunn, Ok thanks – gstackoverflow Aug 08 '17 at 10:06

0 Answers0