以下是我用于在send_sms表中插入新行的查询:
DELIMITER $$
CREATE TRIGGER before_insert;
BEFORE UPDATE ON send_sms
FOR EACH ROW BEGIN
INSERT INTO send_sms
(sender, receiver, msgdata)
VALUES
('123456', '654321', 'hello trigger')
END
DELIMITER ;
...在send_sms表上执行Insert查询之前。我做得对吗?因为我没有得到我想要的东西。
答案 0 :(得分:1)
查询无效,因为存在语法错误,这里是正确的版本
DELIMITER $$
CREATE TRIGGER after_insert -- remove ;
AFTER INSERT ON table_first
FOR EACH ROW BEGIN
INSERT INTO table_second
(value1, rvalue2, value3)
VALUES
('123456', '654321', 'hello trigger'); -- add ;
END
$$ -- add $$
DELIMITER ;