1

I am trying to create a trigger in mysql using the following:

CREATE TRIGGER ins_daft BEFORE INSERT ON jos_ezrealty
FOR EACH ROW BEGIN 
SET preschool = livingarea*10.76391041671
END;

When I do I get the following error:

Error
SQL query:

CREATE TRIGGER ins_daft BEFORE INSERT ON jos_ezrealty
FOR EACH
ROW BEGIN 
SET preschool = livingarea * 10.76391041671 END

MySQL said: Documentation

#1193 - Unknown system variable 'preschool' 

I am trying to have the value of one field converted to square feet by multiplying by 10.76391041671. Can anyone see what I am doing wrong?

Thank you.

1 Answer 1

4

Any time you want to reference the columns of a row that fired the trigger, qualify them like NEW.column_name.

Otherwise the SET command thinks you want to set a MySQL configuration variable called preschool.

Sign up to request clarification or add additional context in comments.

2 Comments

I made the change and now I get this:SQL query: CREATE TRIGGER ins_daft BEFORE INSERT ON jos_ezrealty FOR EACH ROW BEGIN SET NEW.preschool = 'livingarea*10.76391041671' END MySQL said: Documentation #1064 - 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 'END' at line 3
Each statement in the body of the trigger needs a semicolon (;) to terminate it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.