MongoDB concatenate strings from two fields into a third field

前端 未结 8 1440
逝去的感伤
逝去的感伤 2020-12-09 09:14

How do I concatenate values from two string fields and put it into a third one?

I\'ve tried this:

db.collection.update(
  { \"_id\": { $exists: true          


        
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 10:20

    **

    in my case this $concat worked for me ...

    **

    db.collection.update( { "_id" : {"$exists":true} }, 
       [ { 
           "$set" : { 
                     "column_2" :  { "$concat" : ["$column_4","$column_3"] }
                    }
          }
       ]
    

提交回复
热议问题