tags:

views:

44

answers:

0

Update a field by +1 (or any other integer increment) in table in sql, (PHP - Im using txt-db-api) in a single update statement.

Something like

UPDATE tablename 
  SET current_value = current_value+1 
where condition=true

Although field is integer type but is not Auto_Increment type.

Edit

Actually I am not using MySQL but a flat text db called txt-db-api in PHP. I elaborate it as, increment a field value without knowing actual value or retrieving it (only knowing that it is an integer type) by any constant number or +1 (in my case).

CODE IS LIKE THIS:

$ip_who=$_SERVER['REMOTE_ADDR'];

$query="UPDATE ratingtable SET rating_value='".valuealready+1."', rater_ip='$ip_who';