0
我有這樣的代碼在這裏:MySQL的插入後觸發澄清
CREATE TRIGGER testTrigger
AFTER INSERT ON users
BEGIN
DECLARE @uid VARCHAR(60)
SET @uid = (SELECT userid FROM inserted)
INSERT INTO user_locations (id,uid,lat,lng) VALUES (0,@uid,5.0,5.0)
END;
的想法是儘快插入產生的用戶ID爲其他表一起其他一些數據,因爲它擊中了第一個「用戶」表,但phpMyAdmin的給此錯誤代碼:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
BEGIN
DECLARE @uid VARCHAR(60)
SET @uid = (SELECT userid FROM inserted)
at line 3
有人可以澄清爲什麼這個觸發器是壞的嗎?
您缺少FOR EACH ROW – Mihai