In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
MySQL commonly used SQL statements in the MongoDB which are written, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
If you have been using MySQL for a long time and are eager to try MongoDB, this simple article can help you get into character faster.
What are the common SQL statements of MySQL written in MongoDB?
Query:
MySQL:
SELECT * FROM user
Mongo:
Db.user.find ()
MySQL:
SELECT * FROM user WHERE name = 'starlee'
Mongo:
Db.user.find ({'name':' starlee'})
Insert:
MySQL:
INSERT INOT user (`name`, `age`) values ('starlee',25)
Mongo:
Db.user.insert ({'name':' starlee', 'age': 25})
ALTER TABLE user... .
But in MongoDB, all you need is:
Db.user.insert ({'name':' starlee', 'age': 25,' email': 'starlee@starlee.com'})
Delete:
MySQL:
DELETE * FROM user
Mongo:
Db.user.remove ({})
MySQL:
DELETE FROM user WHERE age
< 30 Mongo: db.user.remove({'age' : {$lt : 30}}) $gt : >; $gte: > =; $lt: <; $lte: 20
Mongo:
Db.user.distinct ('name', {' age': {$lt: 20}})
MySQL:
SELECT name, sum (marks) FROM user GROUP BY name
Mongo:
Db.user.group ({
Key: {'name': true}
Cond: {'name':' foo'}
Reduce: function (obj,prev) {prev.msum + = obj.marks;}
Initial: {msum: 0}
})
MySQL:
SELECT name FROM user WHERE age < 20 Mongo: db.user.find ('this.age < 20, {name: 1}) found that many people are searching for data inserted in the MongoDB loop. The following is the method of inserting data in the MongoDB loop: for (var iCompositi)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.