0
我做错了什么?Mysql TIMESTAMP触发器不起作用
我table1
在INSERT数据table1
我有触发:
BEGIN
INSERT INTO table2 (`c_id`, `date`, `product_id`, `price`)
VALUES (
NEW.c_id,
NEW.date = CURRENT_TIMESTAMP,
NEW.product_id,
NEW.price
); END
CREATE TABLE `table2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`c_id` int(11) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`product_id` int(11) NOT NULL,
`price` decimal(9,2) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `c_data` (`c_id`,`date`,`product_id`)
) ENGINE=MyISAM AUTO_INCREMENT=30 DEFAULT CHARSET=latin1;
至于结果,我得到的日期
MySQL版本28年6月5日0000-00-00 00:00:00
从插入查询中删除'date'和NEW.date = CURRENT_TIMESTAMP。默认情况下,mysql会为它设置日期。 –
MySQL version 5.6.28 –
@MangeshSatheIND你的意思是:BEGIN插入competitor_pricing('competitor_id','variant_id','price')值(NEW.competitor_id,NEW.variant_id,NEW.price);结束 ??? –