mongo数据库的各种查询语句示例

11、db.users.find() 2 -- db.getCollection('users').find({}) 3 -- select * from users 4 52、db.users.find({"age" : 27}) 6 -- select * from users where age = 27 73、db.users.find({"username" : "joe", "age" : 27}) 8 -- select * from users where "username" = "joe" and age = 27 9 104、db.users.find({}, {"username" : 1, "email" : 1}) 11 -- select username, email from users 125、db.users.find({}, {"username" : 1, "_id" : 0}) 13 -- no case 14 -- 即时加上了列筛选,_id也会返回,必须显式的阻止_id返回 15 166、db.users.find({"age" : {"$gte" : 18, "$lte" : 30}}) 17 -- select * from users where age >=18 and age <= 30 18 -- $lt(<) $lte(<=) $gt(>) $gte(>=) 197、db.users.find({"username" : {"$ne" : "joe"}}) 20 -- select * from users where username != "joe" 21 228、db.users.find({"ticket_no" : {"$in" : [725, 542, 390]}}) 23 -- select * from users where ticket_no in (725, 542, 390) 249、db.users.find({"ticket_no" : {"$nin" : [725, 542, 390]}}) 25 -- select * from users where ticket_no not in (725, 542, 390) 26 2710、db.users.find({"$or" : [{"ticket_no" : 725}, {"winner" : true}]}) 28 -- select * form users where ticket_no = 725 or winner = true 29 3011、db.users.find({"username" : {"$in" : [null], "$exists" : true}}) 31 -- select * from users where username is null 32 -- 如果直接通过find({"username" : null})进行查询,那么连带"没有username"的纪录一并筛选出来 3312、db.users.find({"username" : {"$nin" : [null]}}) 34 -- db.users.find({"username" : {"$ne" : null}}) 35 -- select * from users where username is not null
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

sql注入

反引号是个比较特别的字符,下面记录下怎么利用0x00SQL注入反引号可利用在分隔符及注释作用,不过使用范围只于表名、数据库名、字段名、起别名这些场景,下面具体说下1)表名payload:select\from\users\whereuser\_id1limit0,1;!(https://o