Updating multiple fields using update query

Posted by / 26-Mar-2020 05:52

In other words, a target row shouldn't join to more than one row from the other table(s).

If it does, then only one of the join rows will be used to update the target row, but which one will be used is not readily predictable.

If only one field of a document should be updated the "$set" operator can be used.

Values that are not specified in this update command will not be available in the document anymore.

Only the '_id' field must not be specified since it's an internal field maintained by Mongo DB.

So far all Mongo DB update queries only updated/replaced exactly one document even though the selector matched multiple documents.

To update all matching documents an addional option must be set: db.customers.update( , , ); This command returns the following result: Write Result() In this example n Matched shows that two documents have been found by the document selector query but n Modified shows that only one document have been updated by the update command.

updating multiple fields using update query-85updating multiple fields using update query-8updating multiple fields using update query-87

When the zip code is 94101 it will be 94102 after the update.

One thought on “updating multiple fields using update query”

  1. universe, and before you know it you’re imagining what house you’d be sorted into and which magical job you’d have after graduating from Hogwarts. If you could marry anyone in the series, who would it be?