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
update computers set total_disk_space = (whatever that row's current total_disk_space is plus 120)
For the entire Table then:
Update Computers
Set Total_Disk_Space = Total_Disk_Space + 120;
If, you only want to update certain ones, then you'd need filters, for example:
Update Computers
Set Total_Disk_Space = Total_Disk_Space + 120
Where PurchaseDate BETWEEN '1/1/2008' AND GETDATE();
Yeah:
update computers set total_disk_space = total_disk_space + 120;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With