假设我们有两张table。
第一个表是项目- id, title
.
第二张table是历史- id, title, action, user
.
“this user inserted this item”的插入后触发器如下:
INSERT INTO history (title, action, user) VALUES (NEW.title, 'INSERT', @phpUserId);
如果我想插入新项目,我可以这样做。
SET @phpUserId = 123;
INSERT INTO items (title) VALUES ('My best item');
在这种情况下,触发器工作正常。
但问题是,当我向变量中添加一些文本时-例如 SET @phpUserId = "library123";
-在这一刻,触发器无法获取该变量。
你知道为什么只传递整数变量吗?
1条答案
按热度按时间zzwlnbp81#
好消息你的扳机没问题,这是证据