In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.