这是一个MySQL触发器
IF ... THEN
#User Lost
UPDATE users SET h2h_money = h2h_money - ( SELECT entry FROM contests WHERE contestid = new . contestid ) WHERE username = new . username;
#User Won
UPDATE users SET h2h_money = h2h_money + new . prize WHERE username = new . username;
#Money Entered
UPDATE users SET h2h_money_entered = h2h_money_entered + ( SELECT entry FROM contests WHERE contestid = new . contestid ) WHERE username = new . username;
#Money输入下的查询有效,但#User Lost不起作用。它不会从用户赢得的总金额中扣除入场费。如果它有所不同,则h2h_money的默认值为0.
如果重要的话,字段类型是小数。