【问题标题】:Updating table in trigger after insert on the same table在同一个表上插入后更新触发器中的表
【发布时间】:2016-03-14 10:55:43
【问题描述】:

在同一张表上插入数据后,我创建了一个触发器来更新同一张表

听到是我的密码

BEGIN
SET @sub=(select core_1 from student_detail where roll_no=new.roll_no);
SET @crdt=(select credit from subject_entry where sub_name=@sub);
IF(new.total>89 && new.total<101) 
THEN
SET new.grade='O';
SET new.gp=10;
SET new.cp=@crdt;
END IF;
END

它通过错误子查询返回多行,同时在表上插入数据

【问题讨论】:

    标签: mysql


    【解决方案1】:

    如果要在正在处理的记录中设置值,请使用 before 更新/插入触发器,而不是 after 更新。

    这可能就是您需要做的所有事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-18
      • 2017-12-18
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      相关资源
      最近更新 更多