简体   繁体   中英

Can't find out what's wrong with this MySQL event syntax

I'm trying to create a MySQL event, and this is the syntax I'm using:

CREATE EVENT test
    ON SCHEDULE AT FROM_UNIXTIME(1428005286)
    DO
      BEGIN
        UPDATE blog_posts SET status = 'published' WHERE id = 5;
      END

When I run it on Node.js (with the mySQL adapter, under Sails.js), I get no error, but the event doesn't get created. When I run it directly through phpMyAdmin, I get:

#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 '' at line 5 

I have also tried adding a semicolon to END, making it END; , and removing all semicolons, and it returns a slightly similar error:

 #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 6

I have no idea why this is happening. Any help is appreciated. Thanks.

You probably need to start with: create DEFINER= root @ localhost ...
Also, since this is a one-liner, you don't need BEGIN..END

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM