Sample data:
{
"CNo": "11",
"Details": [
{
"Ddate": Isodate ("2017-04-01t00:00:00.000+0800"),
"BNo": "No00000000497"
},
{
"Ddate": Isodate ("2017-05-01t00:00:00.000+0800"),
"BNo": "No00000000497"
},
{
"Ddate": Isodate ("2017-06-01t00:00:00.000+0800"),
"BNo": "No00000000497"
}
]
}
{
"CNo": "12",
"Details": [
{
"Ddate": Isodate ("2017-04-01t00:00:00.000+0800"),
"BNo": "No00000000497"
},
{
"Ddate": Isodate ("2017-05-01t00:00:00.000+0800"),
"BNo": "No00000000497"
},
{
"Ddate": Isodate ("2017-06-01t00:00:00.000+0800"),
"BNo": "No00000000500"
}
]
}
{
"CNo": "13",
"Details": [
{
"Ddate": Isodate ("2017-04-01t00:00:00.000+0800"),
"BNo": "No00000000497"
},
{
"Ddate": Isodate ("2017-05-01t00:00:00.000+0800"),
"BNo": "No00000000497"
},
{
"Ddate": Isodate ("2017-06-01t00:00:00.000+0800"),
"BNo": "No00000000497"
}
]
}
Query condition: ddate equals 2017-06-01, and bno equals No00000000497 data
Correct query statement: {details:{$elemMatch: {"BNo": "No00000000497", "Ddate": Isodate ("2017-10-01t00:00:00.000+0800")}}}
Query results: 11, 13
(Non-exact match/error) query statement: {"details.bno": "No00000000497", "Details.ddate": Isodate ("2017-10-01t00:00:00.000+0800")}
Query results: 11, 12, 13
Full match query for MongoDB inline array