I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):
CREATE TRIGGER TRG_CREATE_INT_SRV_ROW
AFTER INSERT ON survey_details
FOR EACH ROW
BEGIN
IF(New.LossTo == 'Vehicle') THEN
INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo);
ELSE
INSERT INTO survey_other (RefNo) VALUES (New.RefNo);
END IF;
END;
While running the query, the error message displayed is:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5
I am writing this kind of conditional trigger for the first time.
What is wrong with code please?