MongoDB 查询 patients 表中 detail.name 与 detail.dob 字段不全相同且 detail.idCardNo 不为空的数据量
可以使用以下 MongoDB 查询语句:
db.patients.find({
$and: [
{'detail.name': {$ne: 'detail.dob'}},
{'detail.idCardNo': {$ne: null}}
]
}).count()
这个查询语句使用了 MongoDB 的 $and 操作符,它可以将多个查询条件组合起来。第一个条件是 {'detail.name': {$ne: 'detail.dob'}},意思是 detail.name 字段不等于 detail.dob 字段。第二个条件是 {'detail.idCardNo': {$ne: null}},意思是 detail.idCardNo 字段不等于空。这两个条件使用 $ne 操作符表示不等于。
最后,使用 count() 函数来统计符合条件的数据量。
原文地址: https://www.cveoy.top/t/topic/ofe8 著作权归作者所有。请勿转载和采集!