Python中文
首页
教程
问答
标签
搜索
登录
注册
mongodb中的$and查询没有重新返回结果
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>一般来说,我对使用mongodb和NoSql还比较陌生</p> <p>这是我试图查询的json代码的一个示例</p> <pre><code> { "_id" : ObjectId("5c351ae3d85ef0793dacc041"), "Year" : 2008, "State" : "NY", "Producer Type" : "Commercial Cogen", "Energy Source" : "All Sources", "CO2 (Metric Tons)" : "590,598", "SO2 (Metric Tons)" : "1,094", "NOx (Metric Tons)" : "2,390" } </code></pre> <p>我试图返回所有的结果(如此多的结果),显示纽约州和能源作为煤</p> <pre><code>db.emissions.find({ $and:[{"state":"NY"}, {"energy source": "coal"}]}) </code></pre> <p>它没有返回任何结果</p> <p>谢谢</p> <p><strong>编辑:</strong></p> <pre><code> db.emissions.find("state":"NY","energy source":"coal") </code></pre> <p>以及</p> <pre><code>db.emissions.find({ "State":"NY", "Energy Source": "Coal"}) </code></pre> <p>也不能正常工作</p> <p>但是只要在<code>$and</code>查询中对区分大小写的字母进行排序就可以了!谢谢</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>字段名区分大小写</p> <p>请试一试</p> <pre><code>db.emissions.find({ $and:[{"State":"NY"}, {"Energy Source": "coal"}]}) </code></pre> <p>或者只是</p> <pre><code>db.emissions.find({ "State":"NY", "Energy Source": "coal"}) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
无法使用Django/mongoengine连接到MongoDB(身份验证失败)
6 回答
无法使用Django\u mssql\u后端迁移到外部hos
5 回答
无法使用Django&Python3.4连接到MySql
10 回答
无法使用Django+nginx上载媒体文件
7 回答
无法使用Django1.6导入名称模式
10 回答
无法使用Django1.7和mongodb登录管理站点
2 回答
无法使用Djangoadmin创建项目,进程使用了错误的路径,因为我事先安装了错误的Python
3 回答
无法使用Djangockedi验证CBV中的字段
7 回答
无法使用Djangocketditor上载图像(错误400)
2 回答
无法使用Djangocron进行函数调用
5 回答
无法使用Djangofiler djang上载文件
10 回答
无法使用Djangokronos
1 回答
无法使用Djangomssql provid
10 回答
无法使用Djangomssql连接到带有Django 1.11的MS SQL Server 2016
2 回答
无法使用Djangomssq迁移Django数据库
6 回答
无法使用Djangonox创建用户
1 回答
无法使用Djangopyodb从Django查询SQL Server
3 回答
无法使用Djangopython3ldap连接到ldap
7 回答
无法使用Djangoredis连接到redis
2 回答
无法使用Django中的FK创建新表
2 回答