Jump to content

How to add data to existing data to get a new total?


lookee

Recommended Posts

I am attempting to add a quantity to an exisiting field in a Mysql table.

 

For instance.

 

Current_Inventory 8

 

I would like to increase the amount of 8 by 4 to equal 12.

 

Code

 

$query = "UPDATE nixon SET quantity=$books WHERE group_id=9";

mysql_query($query);

 

Right now, the above code simply replaces 8 with 4.  How would I write the code to add the amounts together?

 

Would I have to do something like

- fetch the current inventory and assign a $current_string to that amount

- assign a $new_string to the addition amount

- add the two amounts together by assigning the sum of both to an

  $updated_string?

 

Or is there a simple Mysql command that will do this?

 

Thanks!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.