MongoDB concatenate strings from two fields into a third field

前端 未结 8 1462
逝去的感伤
逝去的感伤 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:05

    You could use $set like this in 4.2 which supports aggregation pipeline in update.

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

提交回复
热议问题