mysql错误1064中创建触发器时出现问题?

时间:2018-11-17 11:16:45

标签: mysql sql

在mysql中创建触发器时遇到问题:

错误 SQL查询:

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{
    /**
     * Indicates whether the XSRF-TOKEN cookie should be set on the response.
     *
     * @var bool
     */
    protected $addHttpCookie = true;

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        //
    ];
}
  

MySQL说:文档   1064-您的SQL语法有误;查看与您的MySQL服务器版本相对应的手册以使用正确的语法   在第11行的“”附近

1 个答案:

答案 0 :(得分:2)

请找到包含有关错误的内嵌注释的固定触发器:

-- need to define DELIMITER to something else other than ;
DELIMITER $$

CREATE TRIGGER product_after_insert
AFTER INSERT
   ON FRUITS FOR EACH ROW

BEGIN
      INSERT INTO products
      (category,
       product_id)
      VALUES
      ('fruit',
        New.ID); -- ; was missing for statement execution

END $$  -- End the Begin clause

DELIMITER ;  -- Redefine the delimiter back to ;