I'm trying to make a trigger that will remove rows from one table based on select in another table
table operatorpositions
columns operator, line, pos
table positiontags
columns line, position, tag
table operatortags
columns operator, tag
My trigger looks like this
CREATE TRIGGER removeOperatorPosition AFTER DELETE ON operatorpositions
FOR EACH ROW
BEGIN
DELETE FROM operatortags WHERE gen = NEW.operator
AND tag = (SELECT tag FROM positiontags WHERE position = NEW.pos AND line = NEW.line);
END;
Problem is there can be multiple tags for one position, so subquery will return multiple rows. How do I need to change this so it will work with multiple tags?