I am trying to write a trigger to not allow an update of a relation if a statement is true, and I am running into some trouble
CREATE TRIGGER noPriceLowerSpeed
BEFORE UPDATE
ON pc
FOR EACH ROW
BEGIN
IF(new.speed IS IN (SELECT speed FROM pc AS pc1) AND pc1.price < new.price)
THEN DROP new
END IF;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN (SELECT speed FROM pc AS pc1) AND pc1.price < new.price) THEN DROP new
I am trying to not allow a pc into my pc relation if it has a higher price than a pc with the same speed.
How might I write this trigger to just not allow the update?