0

the sql I wrote is as below:

create

trigger test_schedule_trigger after update on tw_task
as
update tw_test_schedule test, tw_task task
set test.name = task.name,test.`type`=task.`type`,test.is_deleted=task.is_deleted,test.gmt_modified=task.gmt_modified;
where tw_test_schedule.task_id = tw_task.id;

the error description is:

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 'where tw_test_schedule.task_id = tw_task.id' at line 1

2 Answers 2

1

Try remove the ; before the WHERE

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

Comments

0

You have a ; semicolon at the end of your set line:

                                                right here
                                                     v
set blah, blah, test.gmt_modified = task.gmt_modified;
where blah ...

This is terminating the statement, meaning that the where is not really valid SQL. Just get rid of that semicolon.

4 Comments

I tried as you suggested, howerer it remained unsolved. The description after I modified is "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 'asupdate tw_test_schedule test, tw_task task set test.name = task.name,test.`' at line 3"
@eric, then check your string near that point. I'm pretty certain asupdate is not valid SQL either :-)
sorry for my ignorance, i'm a newcomer of mysql. i made a modification but it turned out to commit the same mistake.create trigger test_schedule_trigger after update on tw_task for each row begin update tw_test_schedule test, tw_task task set test.name = task.name,test.type=task.type,test.is_deleted=task.is_deleted,test.gmt_modified=task.gmt_modified where test.task_id=task.id end;The description is 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 8.
@eric, you don't need begin/end in this case because it's a single statement. But, if you do use it, every statement within it must be terminated with a semicolon. That means putting one before the end.

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.