<p>Can databases (MySQL in particular, any SQL--MS, Oracle, Postgres--in general) do mass updates, and figure out on their own what the new value should be? Say for example I've got a database with information about a bunch of computers, and all of these computers have drives of various sizes--anywhere from 20 to 250 GB. Then one day we upgrade every single computer by adding a 120 GB hard drive. Is there a way to say something like</p>

<pre><code>update computers set total_disk_space = (whatever that row's current total_disk_space is plus 120)
</code></pre>

[{'answer_id': 79305, 'author': 'Tom Leys', 'author_id': 11440, 'author_profile': 'https://Stackoverflow.com/users/11440', 'pm_score': 2, 'selected': False, 'text': '<p>Yeah:</p>\n\n<pre><code>update computers set total_disk_space = total_disk_space + 120;\n</code></pre>\n'}, {'answer_id': 79313, 'author': 'Stephen Wrighton', 'author_id': 7516, 'author_profile': 'https://Stackoverflow.com/users/7516', 'pm_score': 3, 'selected': False, 'text': "<p>For the entire Table then:</p>\n\n<pre><code>Update Computers \nSet Total_Disk_Space = Total_Disk_Space + 120;\n</code></pre>\n\n<p>If, you only want to update certain ones, then you'd need filters, for example:</p>\n\n<pre><code>Update Computers\nSet Total_Disk_Space = Total_Disk_Space + 120\nWhere PurchaseDate BETWEEN '1/1/2008' AND GETDATE();\n</code></pre>\n"}, {'answer_id': 79329, 'author': 'Matt Haley', 'author_id': 14142, 'author_profile': 'https://Stackoverflow.com/users/14142', 'pm_score': 2, 'selected': False, 'text': "<p>In your example, if total_disk_space is an INT you can use:</p>\n\n<pre><code>UPDATE computers\nSET total_disk_space = total_disk_space + 120;\n</code></pre>\n\n<p>I you're storing character data, then it will be far more interesting.</p>\n"}]
['https://Stackoverflow.com/questions/79292', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14701/']