MySql:SELECT查询中的count + 1

时间:2015-09-28 15:26:09

标签: mysql sql select sql-update

我如何一次在SELECT查询中添加更新。 我希望从SELECTed行计算一个字段。

SELECT * FROM `_server` order by hits asc LIMIT 1 (update `_server` set `hits`=hits+1)

1 个答案:

答案 0 :(得分:1)

您可以在order by中使用limitupdate

update `_server`
    set hits = hits + 1
    order by hits asc
    limit 1;