MongoDB語(yǔ)法與MySql語(yǔ)法對(duì)比

MongoDB語(yǔ)法 MySql語(yǔ)法
db.test.find({'name':'foobar'}) select * from test where name='foobar'
select * from test where name='foobar' select *from test
db.test.find({'ID':10}).count() select count(*) from test where ID=10
db.test.find({'ID':10}).count() select count(*) from test where ID=10
db.test.find().skip(10).limit(20) 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:20}}) 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':25}) insertinto test ('name','age') values('foobar',25)
db.test.remove({}) delete * from test
db.test.remove({'age':20}) delete test where age=20
db.test.remove({'age':{$lt:20}}) delete test where age<20
db.test.remove({'age':{$lte:20}}) delete test where age<=20
db.test.remove({'age':{$gt:20}}) delete test where age>20
db.test.remove({'age':{$gte:20}}) delete test where age>=20
db.test.remove({'age':{$ne:20}}) delete test where age!=20
db.test.update({'name':'foobar'},{$set:{'age':36}}) update test set age=36 where name='foobar'
db.test.update({'name':'foobar'},{$inc:{'age':3}}) update test set age=age+3 where name='foobar'
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • MongoDB 與 MySQL 對(duì)比 由于公司系統(tǒng)使用MongoDB,雖然之前了解,但并沒(méi)有深入學(xué)習(xí)MongoDB...
    AQ王浩閱讀 3,770評(píng)論 2 25
  • 1.更高的寫(xiě)入負(fù)載 默認(rèn)情況下,MongoDB更側(cè)重高數(shù)據(jù)寫(xiě)入性能,而非事務(wù)安全,MongoDB很適合業(yè)務(wù)系統(tǒng)中有...
    04b49d3875c7閱讀 759評(píng)論 0 2
  • 繼上一篇文章談到語(yǔ)法和單詞到底怎么學(xué)這個(gè)問(wèn)題,筆者認(rèn)為,對(duì)于以英語(yǔ)為第二外語(yǔ)的學(xué)習(xí)者來(lái)說(shuō),語(yǔ)法是基礎(chǔ),否則不能用合...
    靈小貓閱讀 15,249評(píng)論 0 66
  • 今天的Unique例會(huì),后半段由即興改為談博士工作坊,講了CL手冊(cè)的使用。談博士自己發(fā)現(xiàn)是很大一個(gè)坑,因?yàn)閰⑴c型的...
    冰小寒閱讀 250評(píng)論 0 1
  • 這幾天一直是陰雨綿綿,時(shí)大時(shí)小,也一直沒(méi)有專(zhuān)家們預(yù)測(cè)的那么暴虐和可怕。心中那份小小的期待貌似真的落了空,想想也好,...
    純流氓藝術(shù)家閱讀 229評(píng)論 0 0

友情鏈接更多精彩內(nèi)容