插入更新后触发 - 更新表

时间:2017-12-28 18:49:40

标签: mysql sql triggers

我在MySql中有这个触发器:

$category = Category::select()
->where('slug', $slug)
->with(['webshops' => function ($query) {
    $query->groupBy('webshops.id')
    ->orderBy('webshops.name')
    ->with(['brands' => function ($query) {
        $query->where('active', 1)
        ->where('replace_by', NULL)
        ->orderBy('name');
    }])
    ->simplePaginate(3);
}])
->first();

如果我将数据插入“内容”表中,则会出现此错误:

CREATE DEFINER=`root`@`localhost` TRIGGER `mydatabase`.`content_AFTER_INSERT` AFTER INSERT ON `content` FOR EACH ROW
BEGIN

  UPDATE member
           SET member.points = member.points +10, member.postcountT = member.postcountT +1

           WHERE  member.user_id = NEW.owner;
END

我该如何解决这个问题?感谢。

0 个答案:

没有答案