Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

quick way to add 1 to an integer value in a mysql table

 
   Database Forums (Home) -> PHP RSS
Next:  Mobile Only? Why?  
Author Message
mcyi2mr3

External


Since: Nov 07, 2005
Posts: 2



(Msg. 1) Posted: Fri Nov 18, 2005 12:47 pm
Post subject: quick way to add 1 to an integer value in a mysql table
Archived from groups: alt>php (more info?)

Hi guys

Does anyone know a quick way to add 1 to an integer value in a mysql
table collumn.

The way i use now is to extract the value from the appropriate collumn
using select then use php to create a new value ($newnumber =
$oldnumber +1) and then insert this back into my table.

Is there a faster way to do this where you can get mysql to just add +1
to whatever value is in the collumn? I have a feeling there is but my
mysql knowledge is a bit patchy.

Any help on this will be greatly appreciated.

Thanks

marc

 >> Stay informed about: quick way to add 1 to an integer value in a mysql table 
Back to top
Login to vote
user3152

External


Since: Jan 18, 2005
Posts: 90



(Msg. 2) Posted: Fri Nov 18, 2005 12:59 pm
Post subject: Re: quick way to add 1 to an integer value in a mysql table [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

mcyi2mr3 DeleteThis @lycos.co.uk wrote:
>
> Is there a faster way to do this where you can get mysql to just add +1
> to whatever value is in the collumn?

Yes:

UPDATE the_table SET the_field=the_field + 1 WHERE [condition]

Cheers,
NC

 >> Stay informed about: quick way to add 1 to an integer value in a mysql table 
Back to top
Login to vote
mcyi2mr3

External


Since: Nov 07, 2005
Posts: 2



(Msg. 3) Posted: Fri Nov 18, 2005 1:20 pm
Post subject: Re: quick way to add 1 to an integer value in a mysql table [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

awesome that was just what i was looking for.

cheers

marc
 >> Stay informed about: quick way to add 1 to an integer value in a mysql table 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
noob question - integer output format, use of SUM in MySql - A bunch of small things are frustrating me in trying to do some simple stuff with MySQL and php. For example, I have am trying to sum the data in a particular field, then output the result. Here is the sequence I'm using in php to do so: ..

really big integer - I need to calculate the sum of the following numbers 1+ 11 + 111 + 1111 + ......+ 1111.....11111 (the last one is a number made by 2002 1's ) so, I wrote $res =0; for ($i = 1; $i<2003; $i++){ echo str_repeat("1", $i).'<br>'; ...

table exists in php MySql - I have 2 requirements that I don't know how to implement in php using MySql. 1) I want to see if a particular table name exists. 2) I want an arrays with the column names that exist in a table. can anyone help me out with that please? Thanks

confused: casting a variable to integer - Hi group, Maybe I should stop working because this seems soo basic. I almost feel ashamed to ask, but here we go. :-/ Consider the following script: <? $name="henk"; echo "\$name=$name <br>"; echo "(int)\$name="...

Integer date to readable dates - I currently work in ASP and am in the process of moving some application across to PHP. At present I store dates in a database in numerical format 38694, which is 08/12/2005. In ASP its very easy to convert this value back into a date, but I cannot fin...
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]