3 回答
TA貢獻1966條經(jīng)驗 獲得超4個贊
投影可以顯式地包括幾個字段。在下面的操作中,find()方法返回與查詢匹配的所有文檔。在結(jié)果集中,只有Item和Qty字段以及默認(rèn)情況下,_id字段在匹配的文檔中返回。
查找({type:‘Food’},{tem:1,qty:1})
item, qty_id.
db.student.find({}, {roll:1, _id:0})roll_id).
_id:0roll_id_id:0roll.
TA貢獻1835條經(jīng)驗 獲得超7個贊
獲取表中沒有_id的所有數(shù)據(jù)
db.student.find({}, {_id:0})
從學(xué)生中選擇*
使用_id從一個字段獲取所有數(shù)據(jù)
db.student.find({}, {roll:1})
選擇學(xué)生名冊
從一個字段獲取所有沒有_id的數(shù)據(jù)
db.student.find({}, {roll:1, _id:0})使用WHERE子句查找指定數(shù)據(jù)
db.student.find({roll: 80})
從ROLO=‘80’的學(xué)生中選擇*
使用WHERE子句和大于條件查找數(shù)據(jù)
db.student.find({ "roll": { $gt: 70 }}) // $gt is greater than
從學(xué)生中選擇*,其中class=‘70’
使用WHERE子句查找大于或等于條件的數(shù)據(jù)
db.student.find({ "roll": { $gte: 70 }}) // $gte is greater than or equal
從學(xué)生中選擇*ROLclass>=‘70’
使用WHERE子句查找小于或等于條件的數(shù)據(jù)
db.student.find({ "roll": { $lte: 70 }}) // $lte is less than or equal
從學(xué)生中選擇<=‘70’
使用WHERE子句查找數(shù)據(jù)并使用小于條件
db.student.find({ "roll": { $lt: 70 }}) // $lt is less than
從學(xué)生中選擇<‘70’
- 3 回答
- 0 關(guān)注
- 1233 瀏覽
添加回答
舉報
