将表列的数据递增一个|| MYSQL

Pra*_*sad 1 php mysql

我有一张像柱子一样的桌子

id || 计数器

如果我做某事(某些事件)我希望计数器的值(在特定的id)增加1,目前iam这样做:

    //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';  
Run Code Online (Sandbox Code Playgroud)

目前iam运行2个查询,请建议我一步到位.

Jos*_*tey 8

只需在数据库中运行数学运算:

update myTable set counter = counter + 1 where id = 'someValue';
Run Code Online (Sandbox Code Playgroud)