情况描述:
CREATE TRIGGER newcuster AFTER INSERT ON products
FOR EACH ROW SELECT ‘customer added‘;
出现错误Not allowed to return a result set from a trigger
查找原因是:MYSQL5以后,不允许触发器返回任何结果,因此使用into @变量名,将结果赋值到变量中,用select调用即可
修改为
CREATE TRIGGER newcustomer AFTER INSERT ON customers
FOR EACH ROW SELECT ‘customer added‘ INTO @add
此时select @add
发现触发器还没开始工作,因为现在还没往customers表中插入数据;
接下来在customers表插入一行数据:
再运行SELECT @add;
可以看到触发器被触发了
学习MySQL出现问题Not allowed to return a result set from a t
原文:https://www.cnblogs.com/shiheyuanfang/p/13668073.html