Search code examples
mysqlmysql-error-1064

create procedure mysql error near ''


My MySQL statement:

CREATE PROCEDURE latest_procedure() BEGIN
DELETE ac.* FROM s_articles_categories AS ac JOIN s_articles AS a ON ac.articleID = a.id WHERE ac.categoryID = 38;
END

I am getting the following 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 '' at line 2 

Any suggestions as to the reason(s) of this error?


Solution

  • You are missing delimiter and need to close the end

    delimiter //
    
    CREATE PROCEDURE latest_procedure() BEGIN
    DELETE ac.* FROM s_articles_categories AS ac JOIN s_articles AS a ON ac.articleID = a.id WHERE ac.categoryID = 38;
    END;//
    
    delimiter ;