Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

+1 because this is much simpler than my approach. I am going to look over the MySQL Stored Procedure Language Book (amazon.com/dp/0596100892) and see it suggests this in the same chapter.
–
RolandoMySQLDBANov 24 '11 at 18:22

BTW congrats on 20000 rep and being the first DBA.SE trusted user.
–
RolandoMySQLDBANov 28 '11 at 17:10

Chapter 11, Pages 254-256 of the book MySQL Stored Procedure Programming under the subheading 'Validating Data with Triggers' suggests making a SELECT of a character string into a dummy integer (in terms of syntax, it is correct, but dies on execution [NO PUN INTENDED]):

CREATE TRIGGER deny_nton_change BEFORE UPDATE ON Schueler_in_Klasse
FOR EACH ROW BEGIN
DECLARE dummy INT;
IF NEW.Schueler_ID != OLD.Schueler_ID OR NEW.Klasse_ID != OLD.Klasse_ID THEN
SELECT 'Cannot Carry Out This Trigger Any Further'
INTO dummy FROM table_you_know_does_not_exist WHERE 1=1 LIMIT 1;
END IF;
END;

This looks smart but I see a problem. The column may not be unique (and probably isn't in this case) so a foreign key towards it, is not advised although allowed in MySQL.
–
ypercubeJul 13 '14 at 11:36

+1 though because if you use the (Schueler_ID, Klasse_ID) combination instead of the one column, it should work.
–
ypercubeJul 13 '14 at 11:39