你能帮我写代码吗?因为我正在为我的项目创建一个表日志。所以我在我的表中包含了一个 TRIGGER 但我的 sql 代码有一个错误。这是我的sql代码。
CREATE TABLE `sales_category` (
`salescatid` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`salescatname` VARCHAR(128) NOT NULL,
`salescatdesc` VARCHAR(512) NOT NULL,
UNIQUE INDEX `salescatname` (`salescatname`),
UNIQUE INDEX `salescatid` (`salescatid`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
CREATE TABLE `category_log` (
`action` ENUM('CREATE','UPDATE','DELETE') NULL DEFAULT NULL,
`id` INT(10) UNSIGNED NOT NULL,
`salescatname` VARCHAR(255) NOT NULL,
`salescatdesc` VARCHAR(255) NOT NULL,
INDEX `id` (`id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;
//Here's the error: SQL error 1054: Unknown column 'id' in 'NEW'
DELIMITER #
CREATE TRIGGER ai_category
AFTER INSERT ON sales_category
FOR EACH ROW
BEGIN
INSERT INTO category_log(action,id,salescatname,salescatedesc)
VALUES('CREATE',NEW.id,NEW.salescatname,NEW.salescatdesc);
END;#
请帮我解决这个问题。我无法发现我的代码哪里出错了。