查询mongodb集合

时间:2017-05-25 22:30:40

标签: mongodb mongodb-query

我正在尝试查询mongodb中的一个集合:

我想了解警察局警长的人数?

我的代码 -

db.EMPDETAILS.find({$and: [{Job Titles: "SERGEANT"}, {Department: "POLICE"}]}).count()

表结构如下所示 - (mongo导入了csv文件 - ) -

> db.EMPDETAILS.find()
{ "_id" : ObjectId("5927455eb048747c01baa981"), "Name" : "ALLISON,  PAUL W", "Job Titles" : "LIEUTENANT", "Department" : "FIRE", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$107790.00", "Hourly Rate" : "" }
{ "_id" : ObjectId("5927455eb048747c01baa982"), "Name" : "BRUNO,  KEVIN D", "Job Titles" : "SERGEANT", "Department" : "POLICE", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$104628.00", "Hourly Rate" : "" }
{ "_id" : ObjectId("5927455eb048747c01baa983"), "Name" : "COOPER,  JOHN E", "Job Titles" : "LIEUTENANT-EMT", "Department" : "FIRE", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$114324.00", "Hourly Rate" : "" }
{ "_id" : ObjectId("5927455eb048747c01baa984"), "Name" : "CRESPO,  VILMA I", "Job Titles" : "STAFF ASST", "Department" : "LAW", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$76932.00", "Hourly Rate" : "" }
{ "_id" : ObjectId("5927455eb048747c01baa985"), "Name" : "DOLAN,  ROBERT J", "Job Titles" : "SERGEANT", "Department" : "POLICE", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$111474.00", "Hourly Rate" : "" }
{ "_id" : ObjectId("5927455eb048747c01baa986"), "Name" : "DUBERT,  TOMASZ ", "Job Titles" : "PARAMEDIC I/C", "Department" : "FIRE", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$91080.00", "Hourly Rate" : "" }
{ "_id" : ObjectId("5927455eb048747c01baa987"), "Name" : "EDWARDS,  TIM P", "Job Titles" : "LIEUTENANT", "Department" : "FIRE", "Full or Part-Time" : "F", "Salary or Hourly" : "Salary", "Typical Hours" : "", "Annual Salary" : "$114846.00", "Hourly Rate" : "" }

我是MongoDB的新手。任何帮助将不胜感激。

0 个答案:

没有答案