简体   繁体   中英

Insert IF value X has increased in an another table

OK. So: I have an app that reads value X from a realtime table and then it inserts the info from that table to a record table, and users of that app can check their what is their record high value X. I'm trying to make it so that it will only do that IF player's value X has increased in the realtime table. Currently it is like this:

 - 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

So now, the record table has inserted every value he has had. I'd like to make it so that it would only do that if Value is higher then the highest value that currently is in the record table:

 - 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

This is to avoid unneccesary lines in the table. Is this even possible to be done with just mysql? Of course it can be done in python, but I have not sufficient skills in that, so this is my only chance atm.

Write some code otherwise I have to put my finger on the trigger ( https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html ). Do you feel lucky punk?

(Clint Eastwood btw)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM