如上图所示,获取期刊论文collection 下的全部 数据sql
条件查询
注意: 请注意选择列的数据类型
1. journal _title = ' Nature'
sql: select * from table_name where journal_title = 'Nature'
mongodb: db.getCollection('期刊论文').find({"journal_title": "Nature"})mongodb
3. volume <= 495
sql: select * from table_name where volume<= 495;
mongodb: db.getCollection('期刊论文').find({"volume":{$lte:"495"}}).pretty()
4. volume >495
sql: select * from table_name where volume> 495;
mongodb: db.getCollection('期刊论文').find({"volume":{$gt:"495"}}).pretty()
5. volume !=495
sql: select * from table_name where volume!= 495;
mongodb: db.getCollection('期刊论文').find({"volume":{$ne:"495"}}).pretty()and, or 查询dom
6. and 查询:
sql: select * from table_name where journal_title = 'Nature' and vulome> 495;
mongodb: db.getCollection('期刊论文').find({"journal_title":"Nature","volume":{$gt:"495"}}).pretty()
7. or 查询:
sql: select * from table_name where journal_title = 'Nature' or vulome> 495;
mongodb: db.getCollection('期刊论文').find({$or: [ {"journal_title":"Nature"},{"volume":{$gt:"495"}}]}).pretty()
8. and 和 or 联合查询:
sql: select * from table_name where volume>52 and journal_title = 'Nature' or journal_title = 'Meccanica';
mongodb: db.getCollection('期刊论文').find({"volume":{$gt:'52'},$or: [ {"journal_title":"Nature"},{"journal_title":"Meccanica"}]}).pretty()spa
获取数据数量
sql: select count(*) from table_name
mongodb: db.getCollection('期刊论文').count()blog
db.getCollection('新闻资讯').aggregate([{$match:{'language':'英文',"title":{$regex:"[\u4e00-\u9fa5]"}}},{$group :{_id:"$domain", num_tutorial : {$sum:1}}}])排序