如何编写查询以获取Mongodb中的工资(在Employees表中)的升序中的员工ID,first_name,last_name,薪水

时间:2017-03-25 06:02:11

标签: mongodb

如何检索员工ID,首先&姓氏,薪水按工资升序使用find()。

This is the structure of Employees.

2 个答案:

答案 0 :(得分:0)

db.employees.find({EMPLOYEE_ID: employeeId}, {FIRST_NAME: 1, LAST_NAME: 1, SALARY: 1}).sort({ SALARY: 1})

答案 1 :(得分:0)

此查询对我有用:

db.Employees.find({},{"last_name":1,"first_name":1,"employee_id":1,"salary":1}).sort({"salary":1}).pretty()