inert into users value(3,5)

db.users.insert({a:3,b:5})

 

 

select a,b from users

db.users.find({}, {a:1,b:1})

select * from users

db.users.find()

select * from users where age=33

db.users.find({age:33})

select a,b from users where age=33

db.users.find({age:33}, {a:1,b:1})

select * from users where age=33 order by name

db.users.find({age:33}).sort({name:1})

select * from users where age>33

db.users.find({age:{$gt:33}})

select * from users where age!=33

db.users.find({age:{$ne:33}})

select * from users where name like "%Joe%"

db.users.find({name:/Joe/})

select * from users where name LIKE "Joe%"

db.users.find({name:/^Joe/})

select * from users where age>33 and age<=40

db.users.find({'age':{$gt:33,$lte:40}})

select * from users order by name desc

db.users.find().sort({name:-1})

select * from users where a=1 and b='q'

db.users.find({a:1,b:'q'})

select * from users limit 10 skip 20

db.users.find().limit(10).skip(20)

select * from users where a=1 or b=2

db.users.find( { $or : [ { a : 1 } , { b : 2 } ] } )

select * from users limit 1

db.users.findOne()

select order_id from orders o, order_line_items li where li.order_id=o.order_id and li.sku=12345

db.orders.find({"items.sku":12345},{_id:1})

select customer.name from customers,orders where orders.id="q179" and orders.custid=customer.id

var o = db.orders.findOne({_id:"q179"});

var name = db.customers.findOne({_id:o.custid})

 

 

select distinct last_name from users

db.users.distinct('last_name')

select count(*y)

from users

db.users.count()

select count(*y)

from users where age > 30

db.users.find({age: {'$gt': 30}}).count()

select count(age) from users

db.users.find({age: {'$exists': true}}).count()

 

 

create index myindexname on users(name)

db.users.ensureIndex({name:1})

create index myindexname ON users(name,ts desc)

db.users.ensureIndex({name:1,ts:-1})

 

 

explain select * from users where z=3

db.users.find({z:3}).explain()

 

 

update users set a=1 where b='q'

db.users.update({b:'q'}, {$set:{a:1}}, false, true)

update users set a=a+2 where b='q'

db.users.update({b:'q'}, {$inc:{a:2}}, false, true)

 

 

delete from users where z="abc"

db.users.remove({z:'abc'});

mongodb与SQL常见语句对照的更多相关文章

  1. MongoDB对应SQL语句

    -------------------MongoDB对应SQL语句------------------- 1.Create and Alter     1.     sql:         crea ...

  2. SQL中常见语句

    SQL中常见语句笔记: --替换字段中的回车符和换行符 ) ), '') --删除表命令 DROP TABLE [dbo].[MGoods_Test] --删除表中数据命令 DELETE FROM [ ...

  3. mongodb 跟踪SQL语句及慢查询收集

    有个需求:跟踪mongodb的SQL语句及慢查询收集 第一步:通过mongodb自带函数可以查看在一段时间内DML语句的运行次数. 在bin目录下面运行  ./mongostat -port 端口号  ...

  4. mongodb 操作语句与sql操作语句对比

    上行:SQL 操作语句 下行:Mongo 操作语句 CREATE TABLE USERS (a Number, b Number) db.createCollection("mycoll&q ...

  5. Mongodb 与 SQL 语句对照表

    In addition to the charts that follow, you might want to consider the Frequently Asked Questions sec ...

  6. [转]MySQL 最基本的SQL语法/语句

    MySQL 最基本的SQL语法/语句,使用mysql的朋友可以参考下.   DDL-数据定义语言(Create,Alter,Drop,DECLARE) DML-数据操纵语言(Select,Delete ...

  7. SQL常见笔试面试题

    sql理论题 1.触发器的作用? 答:触发器是一中特殊的存储过程,主要是通过事件来触发而被执行的.它可以强化约束,来维护数据的完整性和一致性,可以跟踪数据库内的操作从而不允许未经许可的更新和变化.可以 ...

  8. PL/SQL常见设置--Kevin的专栏

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  9. 最基本的SQL语法/语句

    DDL—数据定义语言(Create,Alter,Drop,DECLARE) DML—数据操纵语言(Select,Delete,Update,Insert) DCL—数据控制语言(GRANT,REVOK ...

随机推荐

  1. python 字典获取最大和最小的value

    my_dict = {, , } key_max = max(my_dict.keys(), key=(lambda k: my_dict[k])) key_min = min(my_dict.key ...

  2. JPA使用指南 javax.persistence的注解配置

    @SuppressWarnings("serial") @Entity @Table(name="T_X") public class X implements ...

  3. ABP zero出现Default language is not defined!的错误的解决方法

    打开程序包管理器控制台,把EntityFramework作为默认项目,并且执行Update-Database命令 再运行项目

  4. IDEAL葵花宝典:java代码开发规范插件 GenerateAllSetter、ECtranslation、translation、插件

    前言:  GenerateAllSetter: 我们在程序开发过程中,往往要编写这样的类:类的部分或者全部属性不希望让外部世界直接访问,而不用public字段修饰.这样,方法调用成了访问这些属性的唯一 ...

  5. UVA-10410 Tree Reconstruction (树重建)

    题目大意:给出对一棵树的BFS遍历序列和DFS遍历序列,求出每一个节点的子节点. 题目分析:在BFS的序列中,子节点的下标一定比父节点的下标至少大1(根节点与第一个子节点除外),即pos[fa]+1& ...

  6. System.ComponentModel.DataAnnotations 命名空间和RequiredAttribute 类

    System.ComponentModel.DataAnnotations 命名空间提供定义 ASP.NET MVC 和 ASP.NET 数据控件的类的特性. RequiredAttribute 指定 ...

  7. IOS-网络(ASI使用)

    ASI与AFN区别 区别: 1.底层实现 1>AFN的底层基于OC的NSURLConnection与NSURLSession 2>ASI的底层基于纯C语言的CFNetWork框架 3> ...

  8. Work Queues(点对多)

    Work Queues(点对多) 多个消费者在同一个消息队列中获取消息的情况.在有些应用当中,消费端接收到消息任务需要长时间的处理,如果等上一个消息处理完成以后再取下一个数据进行处理的话,势必会有一些 ...

  9. 054——VUE中vue-router之实例讲解定义一下单页面路由

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. Git创建仓库的方法(github翻译)

    …通过命令行创建一个新的仓库 echo "# GitTest" >> README.md # 船舰一个说明文件,说明内容是 "# GitTest" ...