There is a users table with uid , cash and points , etc.
There is another exchange_log table with the fields userid , summa , etc.
You need to create a trigger that tracks the transfer of the amount from cash to points and records the transfer amount and user id ( uid ) on the exchange_log table.
Here is what I tried but does not work:
CREATE TRIGGER exchange_log AFTER UPDATE ON users FOR EACH ROW IF (NEW.cash != OLD.cash AND NEW.points != OLD.points AND (NEW.points-OLD.points) = (OLD.cash - NEW.CASH)) THEN INSERT INTO exchange_log(uid, summa) VALUES(NEW.uid,NEW.points-OLD.points); END IF Edit the trigger and show my error. Thank.