Jump to content

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


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!

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.