Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:06:35+00:00 2026-06-01T02:06:35+00:00

What I want to do is update multiple documents with different values in 1

  • 0

What I want to do is update multiple documents with different values in 1 query if possible.

for example my documents may look like:

1:

{
   "key": 123,
   "price": 10,

}

2:

{

   "key": 1234,
   "price": 15,

}

…

Then I have a form to update the price, Maybe I want to change #1 to 15 and #2 to 400 in 1 query etc..

Previously I had done multi updates like so:

$db->update('items', array('key' -> array('$in' => $items_to_update)), array('$inc' => array('price' => 1))

Which worked great for updating multiple documents and setting the field to the same value, but I’m not sure how to update multiple documents and updating the value to different values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:06:36+00:00Added an answer on June 1, 2026 at 2:06 am

    From the MongoDB Docs (http://www.mongodb.org/display/DOCS/Atomic+Operations#AtomicOperations-ApplyingtoMultipleObjectsAtOnce):

    You can use multi-update to apply the same modifier to every relevant
    object. By default a multi-update will allow some other operations
    (which could be writes) to interleave. Thus, this will only be
    pseudo-atomic (pseudo-isolated). To make it fullly isolated you can
    use the $atomic motifier:

    not isolated:

    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );
    

    isolated:

    db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false , true );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to update multiple columns in one table based on values in
I want to update multiple rows based on a SELECT sql query. I want
I'm new to MySQL. I'm using this to update multiple rows with different values,
I want to update a single datarow in a datatable using multiple threads. Is
How can I update multiple pages when editing one page? For example, I am
This is basically an extension of Update multiple rows with one query? . I
This may seem like an odd one, but I want to be able to
I want use a stored procedure to update multiple tables in a db. Each
I am basically just trying to update multiple values in my table. What would
I want to build a small .net application which can update multiple databases with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.