is it possible to add a number to a number that is stored in mysql db without extracting the stored number first.

i have a count and i am updating the count periodically but i would like to know if i can update the count while it is in side the table still.

i am not asking about how to update a field completely but to just add the new value to the already stored number.

Recommended Answers

All 3 Replies

update table set number=number+300 where condition;

You mean like this ?

Edit: Or are you talking about concatenation ?

update table SET number = concat( number, "00" ) WHERE condition; //this will concat 00 to the value in number field for that condition
commented: extremely helpful all the time +1

yes sorry i worke it out before then got distracted with something else here is the code that i ended up with.

mysql_query("UPDATE email_count SET sent_messages = sent_messages + $i")

i have not got the where clause in there as this is the only data inside the table.

thanks again for your reply you is always very helpful.

Great :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.