MySQL: return updated rows

后端 未结 6 617
既然无缘
既然无缘 2020-12-03 01:28

I am trying to combine these two queries in twisted python:

SELECT * FROM table WHERE group_id = 1013 and time > 100;

and:



        
6条回答
  •  有刺的猬
    2020-12-03 02:23

    So what you're trying to do is reset time to zero whenever you access a row -- sort of like a trigger, but MySQL cannot do triggers after SELECT.

    Probably the best way to do it with one server request from the app is to write a stored procedure that updates and then returns the row. If it's very important to have the two occur together, wrap the two statements in a transaction.

提交回复
热议问题