incrementing a table column's data by one || mySql

Posted by Praveen Prasad on Stack Overflow See other posts from Stack Overflow or by Praveen Prasad
Published on 2010-05-06T05:01:15Z Indexed on 2010/05/06 5:08 UTC
Read the original article Hit count: 197

Filed under:
|

iam having a table with columns like

id || counter

if i do something (some event) i want the counter's value(at a particular id) to increase by one , currently iam doing this :

    //get current value
    current_value = select counter from myTable where id='someValue'  

    // increase value
    current_value++   

   //update table with current value
    update myTable set counter=current_value where id='someValue';  

currently iam running 2 queries for this, please suggest me some way do it in one step.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php