且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用从另一个表中选择的 MySQL 触发器更新

更新时间:2022-12-10 17:22:14

实际上我自己已经设法解决了这个问题.这是更新后的代码

I've actually managed to solve this myself. Here is the updated code

CREATE TRIGGER `incremental_before_ins_tr` BEFORE INSERT ON `incremental`
FOR EACH ROW
BEGIN
SET NEW.source = (Select source from crm_record
where crm_record.msisdn = new.msisdn order by dat DESC limit 1);
END;

我需要在第 5 行的列值之前指定表名.

I needed to specify the table name prior to the column value on line 5.