开发者

Any way to get old field name in one query on UPDATE with MySQL?

Say you were going to run a开发者_运维知识库n update query & update a field, however you wanted to also retrieve the prior value before the value is updated to the new value. Is there a way to do this in one query? Or do you have to run a SELECT before you run the UPDATE to get the value?


If you were to add a BEFORE UPDATE trigger to the table, during the processing of the trigger both the old and the new values of the affected column(s) would be available. See here for more... http://dev.mysql.com/doc/refman/5.0/en/triggers.html .


I think you will have to run SELECT query before you run the UPDATE one


Maybe if you used stored procedure, you could do the select before the update and return the result once the update is done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜