insert一条数据,mysql报错“unknown column “***” in where clause”,检查后,发现没有错误啊,column是正确的啊,后来想起来自己加了trigger,检查自己trigger正确不, (show triggers),检查Statement,半天没看出来,后来想起来NEW和OLD关键字,原来我定义的trigger里没有指定取得值是NEW还是OLD,如下:
delimiter $
create trigger insert_tradingRecord after insert on tradingrecord for each row
begin
declare c int;
set c=(select stock from product where id=new.productId);
update product set stock=c-new.count where id=new.productId;
end $
delimiter;
修改后ok了,没有报错,顺利插入。