Reputation: 11
Given that I have this database structure.
Table: watchcount
uid steamID sessionid watchcount items
1 234234234 1232432 634 0
I'd like to change column items automatically once watchcount gets updated. After watchcount has been divided by 60, floor the value so that it displays as an integer. Like this:
watchcount items
634 10
Upvotes: 0
Views: 194
Reputation: 12772
Here you go:
create trigger update_items
before update on watchcount
for each row
set new.items = floor(new.watchcount/60);
Upvotes: 1