我正在尝试通过连接两个字段来创建触发器
CREATE TRIGGER format_goods_sn
BEFORE INSERT ON tp_goods
FOR EACH ROW
BEGIN
SET NEW.goods_sn = CONCAT('TP', LPAD(NEW.goods_id, 7, '0'))
END
但我得到警告说SET NEW.goods_sn = CONCAT('TP', LPAD(NEW.goods_id, 7, '0'))
有语法错误?
答案 0 :(得分:0)
我发现只使用单行格式(删除'BEGIN'和'END')就可以解决此问题:
CREATE TRIGGER format_goods_sn
BEFORE INSERT ON tp_goods
FOR EACH ROW
BEGIN
SET NEW.goods_sn = CONCAT('TP', LPAD(NEW.goods_id, 7, '0'))