插入IF值X在另一个表中增加

时间:2014-04-20 10:26:32

标签: mysql sql

行。所以: 我有一个应用程序从实时表中读取值X,然后它将该表中的信息插入记录表,该应用程序的用户可以检查他们的记录高值X是什么。 我试图让它成为只有在玩家的价值X在实时表中增加的时候才会这样做。 目前它是这样的:

 - Player's value X is currently 10 in the real time table
   - It gets inserted into the record table 
 - Player's value X is now 8 the real time table
   - It gets inserted into the record table 
 - Player's value X is now 7 the real time table
   - It gets inserted into the record table

现在,记录表已插入他拥有的每个值。我想这样做,只有当Value高于当前记录表中的最高值时才会这样做:

 - Player's value X is currently 10 in the real time table
   - It gets inserted into the record table 
 - Player's value X is now 8 the real time table
   - It gets ignored cause recordtable.value > realtimetable.value
 - Player's value X is now 7 the real time table
   - It gets ignored cause recordtable.value > realtimetable.value

这是为了避免表中不必要的行。这甚至可以用mysql完成吗?当然它可以在python中完成,但我没有足够的技能,所以这是我唯一的机会atm。

1 个答案:

答案 0 :(得分:2)

写一些代码,否则我必须把手指放在触发器上(https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html)。你觉得朋克很幸运吗?

(Clint Eastwood btw)

相关问题