MySQL触发器除以数字然后将其置于底层

时间:2014-06-29 03:05:09

标签: mysql

鉴于我有这个数据库结构。

表:watchcount

uid      steamID         sessionid       watchcount            items
1       234234234        1232432            634                 0

我想在watchcount更新后自动更改列项。将watchcount除以60后,将值置于显示为整数的值。像这样:

watchcount            items
634                   10 

1 个答案:

答案 0 :(得分:1)

你走了:

create trigger update_items 
before update on watchcount 
for each row 
set new.items = floor(new.watchcount/60);

doc