mongodb中查询和sql查询之间的关系
展开全部
Sql
Mongodb
SELECT * FROM users
Db.users.find()
SELECT a,b FROM users
Db.users.find({},{a:1,b:1})
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},age:{“lte”:40}})
SELECT * FROM users ORDER BY name DESC
Db.user.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})
Mongodb
SELECT * FROM users
Db.users.find()
SELECT a,b FROM users
Db.users.find({},{a:1,b:1})
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},age:{“lte”:40}})
SELECT * FROM users ORDER BY name DESC
Db.user.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})
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
今至电子科技有限公司
2024-08-23 广告
2024-08-23 广告
数据库备份是确保数据安全与业务连续性的关键环节。我们上海今至电子科技有限公司高度重视数据保护,定期执行全面的数据库备份策略。这包括使用先进工具和技术,对关键业务数据进行自动化备份,并存储在安全可靠的外部存储介质或云端。通过定期验证备份的完整...
点击进入详情页
本回答由今至电子科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |