MongoDB Grammar MySQL syntax
Db.test.find ({' name ': ' Foobar '}) <==> select * from test where name= ' Foobar '
Db.test.find () <==> Select *from test
Db.test.find ({' ID ': ten}). Count () <==> Select COUNT (*) from Test where id=10
Db.test.find (). Skip () Limit <==> select * FROM Test limit 10,20
Db.test.find ({' ID ': {$in: [25,35,45]}} <==> select * from Test where ID in (25,35,45)
Db.test.find (). Sort ({' ID ': -1}) <==> select * FROM Test ORDER by Iddesc
Db.test.distinct (' name ', {' ID ': {$lt:}}) <==> select DISTINCT (name) from Testwhere id<20
Db.test.group ({key:{' name ': ' true},cond:{' name ': ' foo '},reduce:function (obj,prev) {prev.msum+=obj.marks;},initial: {msum:0}}) <==> Select Name,sum (Marks) from Testgroup by name
Db.test.find (' this.id<20 ', {name:1}) <==> select name from Test whereid<20
Db.test.insert ({' name ': ' Foobar ', ' age ':] <==>insertinto Test (' name ', ' age ') VALUES (' Foobar ', 25)
Db.test.remove ({}) <==> Delete * from test
Db.test.remove ({' Age ': ') ' <==> delete test where age=20
Db.test.remove ({' age ': {$lt:}}) <==> elete test where age<20
Db.test.remove ({' age ': {$lte:}}) <==> delete test where age<=20
Db.test.remove ({' age ': {$gt:}}) <==> delete test where age>20
Db.test.remove ({' age ': {$gte:}}) <==> delete test where age>=20
Db.test.remove ({' age ': {$ne:}}) <==> delete test where age!=20
Db.test.update ({' name ': ' Foobar '},{$set: {' Age ': '} ') <==> update test set age=36 where Name= ' Foobar '
Db.test.update ({' name ': ' Foobar '},{$inc: {' Age ': 3}} ' <==> update test set
Comparison between MongoDB syntax and existing relational database SQL syntax